Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this exercise, you are to modify the Classify Numbers programming example in this chapter. As written, the program inputs the data from the standard

In this exercise, you are to modify the Classify Numbers programming example in this chapter. As written, the program inputs the data from the standard input device (keyboard) and outputs the results on the standard output device (screen). The program can process only 20 numbers. Rewrite the program 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.
Modify the function getNumber so that it reads a number from the input file (opened in the function main), outputs the number to the output file (opened in the function main), and sends the number read to the function main. Print only 10 numbers per line.
Have the program find the sum and average of the numbers.
Modify the function printResult so that it outputs the final results to the output file (opened in the function main). Other than outputting the appropriate counts, this new definition of the function printResult should also output the sum and average of the numbers on their own line.
An example of the program's output file is shown below:
1431128637173234-265-28685186
26726662-139-380-22510141142
166241-263-1677616931-27167
17-6577-321326546245-26122
The sum of numbers =2165
The average is 54

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Systems Analysis And Synthesis Bridging Computer Science And Information Technology

Authors: Barry Dwyer

1st Edition

0128054492, 9780128054499

More Books

Students also viewed these Databases questions

Question

a. What is the name of the university?

Answered: 1 week ago

Question

3 What are the stages of Kotter and Cohens model of change?

Answered: 1 week ago

Question

4 What is organisation development?

Answered: 1 week ago

Question

5 What activities are employed in OD processes?

Answered: 1 week ago