subject

In this program, you will be reading numbers from a file. You will validate the numbers and calculate the average of all of the valid numbers.
Your program will read in a file with numbers. The numbers will be of type double.
The numbers should be in the range from 0 to 110 (inclusive). You need to count all of the numbers between 0 and 110. You also need to calculate the average of these numbers.
If a number is not valid (that is, it is less than 0 or greater than 110) you need to count it (as a count of invalid values) and you need to write out the number to a file called "invalid-numbers. txt". Values written to file invalid-numbers. txt should be in a fixed format with two digits to the right of the decimal point.
As you did in lab lesson 7 part 1 you need to read in the input file name using cin.
The output from your program will be written to cout. The output must contain the file being processed, the total number of values read in from the file, the number of invalid values read in, the number of valid values read in.
The last thing you need to output is either the average of the valid values or an error message. The average must have two digits of precision to the right of the decimal point and must be in a fixed format. If there is not valid average you should output the message:

An average cannot be calculated
In what case would you display this message?

If the input file cannot be opened, you will need to output a message. Assume the input file name is badinput. txt and it cannot be opened. You will display the following error message to court:

File "badinput. txt" could not be opened
Here is an example of a working program:

Assume the file name read in from cin is:

input. txt
and that input. txt contains:

-12
0
98.5
100
105.5
93.5
88
75
-3
111
89
-12

Your program would output the following:

Reading from file "input. txt"
Total values: 12
Invalid values: 4
Valid values: 8
Average of valid values: 81.19
The contents written out to file invalid-numbers. txt are:

-12
-3
111
-12

You are reading from an input file and you are writing to an output file. Make sure you close both files after you are finished using them. You must do this in your program, you cannot just let the operating system close the files for you.
For tests where there is output written to an output file, the contents of the output file will determine if you passed that test or not. For cases where you have written out to cout the tests will check the output sent to cout. In some cases output will be written to a file and to cout. When this is the case the test will be run twice with the same input. Once to test cout and once to test the contents of the output file. An example of this would be tests 2 and 3. Both use the same input file. Test 2 check the output written to cout and test 3 checks the output written to the file invalid-numbers. txt.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 21.06.2019 22:30
Ted wants to go out to a neighborhood park and shoot pictures of dew drops on grass. he wants to get a low-level angle of the dew drops. which support equipment should ted use? a. mini tripod b. pistol grip c. monopod d. body mount
Answers: 2
question
Computers and Technology, 24.06.2019 11:00
The program below has been generalized to read a user's input value for hourlywage. run the program. notice the user's input value of 10 is used. modify that input value, and run again. generalize the program to get user input values for workhoursperweek and workweeksperyear (change those variables' initializations to 0). run the program. monthsperyear will never change, so define that variable as final. use the standard for naming final variables. ex: final int max_length
Answers: 2
question
Computers and Technology, 24.06.2019 14:30
Which computer network component connects two different networks together and allows them to communicate? a is a node (or a device) that connects two different networks together and allows them to communicate.
Answers: 1
question
Computers and Technology, 24.06.2019 15:30
The idea that, for each pair of devices v and w, thereā€™s a strict dichotomy between being ā€œin rangeā€ or ā€œout of rangeā€ is a simplified abstraction. more accurately, thereā€™s a power decay function f (Ā·) that specifies, for a pair of devices at distance Ī“, the signal strength f(Ī“) that theyā€™ll be able to achieve on their wireless connection. (weā€™ll assume that f (Ī“) decreases with increasing Ī“.) we might want to build this into our notion of back-up sets as follows: among the k devices in the back-up set of v, there should be at least one that can be reached with very high signal strength, at least one other that can be reached with moderately high signal strength, and so forth. more concretely, we have values p1 ā‰„ p2 ā‰„ . . ā‰„ pk, so that if the back-up set for v consists of devices at distances d1ā‰¤d2ā‰¤ā‰¤dk,thenweshouldhavef(dj)ā‰„pj foreachj. give an algorithm that determines whether it is possible to choose a back-up set for each device subject to this more detailed condition, still requiring that no device should appear in the back-up set of more than b other devices. again, the algorithm should output the back-up sets themselves, provided they can be found.\
Answers: 2
You know the right answer?
In this program, you will be reading numbers from a file. You will validate the numbers and calculat...
Questions
question
Mathematics, 07.07.2019 23:00
question
Social Studies, 07.07.2019 23:00
Questions on the website: 13722363