Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this exercise, i need help modifying the Classify Numbers programming example in this chapter. As written, the program inputs the data from the standard

In this exercise, i need help modifying 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:

143 11 286 37 173 234 -265 -286 85 186 267 266 62 -139 -3 80 -225 10 141 142 166 241 -26 3 -167 76 169 31 -27 167 17 -65 77 -32 13 265 46 245 -261 22 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_2

Step: 3

blur-text-image_3

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

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

9. What is a unilateral transfer?

Answered: 1 week ago

Question

Ear part and its functions ?

Answered: 1 week ago

Question

The membranous labyrinth contains?

Answered: 1 week ago

Question

The organ of corti is present in.....?

Answered: 1 week ago

Question

The border between the middle and inner ear is formed by......?

Answered: 1 week ago

Question

It receives sound vibration and passes to the eardrum?

Answered: 1 week ago