subject

The numbers need to be read in as type double. the calculations need to be done using type double as well.
you must properly handle end of file conditions.
you must properly open and close any files.
your program needs to contain as least 3 functions, main, and two (or more) additional functions. the main function should be the driver and delegate work to the other functions. remember, if you are going to pass an ifstream or ofstream to a function, you need to pass is by reference.
failure to follow the c++ requirements could reduce the points received from passing the tests.
general overview
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.
your program needs to contain as least 3 functions, main, and two (or more) additional functions. the main function should be the driver and delegate work to the other functions. remember, if you are going to pass an ifstream or ofstream to a function, you need to pass is by reference.
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 fixed format with two digits to the right of the decimal point.
as you did in lab lesson 9 part 1 you need to read in the input file name using cin.
you need to properly handle end of file conditions. see lab lesson 9 part 1 for details on reading files.
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 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 cout
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.
failure to follow the requirements for lab lessons can result in deductions to your points, even if you pass the validation tests. logic errors, where you are not actually implementing the correct behavior, can result in reductions even if the test cases happen to return valid answers. this will be true for this and all future lab lessons.
expected output
there are eight tests. some tests are parts 1 and 2 of one test. test 1 uses an input file that contains only valid values. test 2 tests an input file that does not exist. test 3 and 4 each have two parts. the first part tests the output to cout and the second part tests the contents of the output file invalid-numbers. txt. the final two tests have just one part.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 13:30
Drag the tiles to the correct boxes to complete the pairs. match the errors with their definitions. #name #value #ref when a formula produces output that is too lengthy to fit in the spreadsheet cell arrowright when you enter an invalid cell reference in a formula arrowright when you type text in cells that accept numeric data arrowright when you type in a cell reference that doesn’t exist arrowright reset next
Answers: 1
question
Computers and Technology, 24.06.2019 01:00
What shows the web address of the page that is currently displayed in the workspace? status window toolbar location bar internet box
Answers: 1
question
Computers and Technology, 24.06.2019 01:30
How can you make your column headings stand out?
Answers: 1
question
Computers and Technology, 24.06.2019 09:30
Atype of researcher who uses computers to make sense of complex digital data
Answers: 1
You know the right answer?
The numbers need to be read in as type double. the calculations need to be done using type double as...
Questions
question
English, 14.12.2020 21:50
question
Social Studies, 14.12.2020 21:50
question
English, 14.12.2020 21:50