Taiwo A.

asked • 05/04/22

how is this done??

Write a complete C++ command to implement a "Sum of Numbers in Range" (sonir) program. Place all your code inside the main() routine; do not write any extra user-defined functions. To minimize your writing, you do not have to code any comments. Do not forget to show program structure through indentation.

This program is invoked with zero or more names of files following the executable name on the command-line. If your program is invoked with no arguments, it should do nothing and return silently. Otherwise, for each filename argument (yes, this means you have to "open" and "close" each file) read a stream of real numbers from that file and add together (i.e., total) those numbers in the input that are between -99.71 and 450.225, inclusive, and print this sum to standard output with a precision of one decimal point. Be sure this total is not printed in E-notation.

You may assume that all files specified exist. For each file, a line is printed giving the filename, a colon, and the sum of the in-range numbers. The following example shows the command being invoked with the names of two files, january.dat and hans.dat. The example shows the resulting two lines of output: each line consisting of a filename, a colon, and sum of the in-range numbers.

$ sonir january.dat hans.dat

january.dat: 535679.4

hans.dat:-436.7

1 Expert Answer

By:

Donald W. answered • 05/05/22

Tutor
5.0 (214)

Personalized tutoring in Math and Computer Science

Still looking for help? Get the right answer, fast.

Ask a question for free

Get a free answer to a quick problem.
Most questions answered within 4 hours.

OR

Find an Online Tutor Now

Choose an expert and meet online. No packages or subscriptions, pay only for the time you need.