Write a program that reads data from a data file, the value of which is provided at the end of the problem. Your program is to incorporate the following requirements: Data to the program is input from a file of an unspecified length; that is, the program does not know in advance how many numbers are in the file. Save the output of the program in a file. Write a function called getNumber which reads a number from the input file, outputs the number to the output file and the monitor and sends the input number to the function main. Make sure, both input and out file are being opened in the main program. Write a function called classifyNumber which counts number of even, odd, and zero (occurrences of zero) available in the input file. Have the program find the sum and average of the numbers and print only 10 numbers per line. Write a function called printResult so that it outputs (in output file and monitor) even number of counts, odd number of counts, number of zeros, sum of the numbers and average of the numbers. Make sure output file is being opened in the function main.   Create an input file using the following data: 43 67 82 0 35 28 -64 7 -87 0 0 0 0 12 23 45 7 -2 -8 -3 -9 4 0 1 0 -7 23 -24 0 0 12 62 100 101 -203 -340 500 0 23 0 54 0 76

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Topic Video
Question
100%

Practice problem we were given in C++ to review for test. Thanks

Write a program that reads data from a data file, the value of which is provided at the end of the problem. Your program is to incorporate the following requirements:

  • Data to the program is input from a file of an unspecified length; that is, the program does not know in advance how many numbers are in the file.
  • Save the output of the program in a file.
  • Write a function called getNumber which reads a number from the input file, outputs the number to the output file and the monitor and sends the input number to the function main. Make sure, both input and out file are being opened in the main program.
  • Write a function called classifyNumber which counts number of even, odd, and zero (occurrences of zero) available in the input file.
  • Have the program find the sum and average of the numbers and print only 10 numbers per line.
  • Write a function called printResult so that it outputs (in output file and monitor) even number of counts, odd number of counts, number of zeros, sum of the numbers and average of the numbers. Make sure output file is being opened in the function main.

 

Create an input file using the following data:

43 67 82 0 35 28 -64 7 -87 0 0 0 0 12 23 45 7 -2 -8 -3 -9 4 0

1 0 -7 23 -24 0 0 12 62 100 101 -203 -340 500 0 23 0 54 0 76

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 3 images

Blurred answer
Knowledge Booster
Instruction Format
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education