Computers and Technology

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.

answer
Answers: 2

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 18:30, dpinzoner5952
Which of the following commands is more recommended while creating a bot?
Answers: 1
image
Computers and Technology, 23.06.2019 00:00, destinysmithds7790
Suppose you have 9 coins and one of them is heavier than others. other 8 coins weight equally. you are also given a balance. develop and algorithm to determine the heavy coin using only two measurements with the of the balance. clearly write your algorithm in the form of a pseudocode using the similar notation that we have used in the class to represent sorting algorithms
Answers: 1
image
Computers and Technology, 24.06.2019 15:50, coralaguilar1702
Andy would like to create a bulleted list. how should he do this? andy should click on the bullet icon or select the bullet option from the menu and then type the list. andy should press the shift key and the 8 key at the beginning of each line of text. andy should type the text and then click on the bullet command. andy should press return and the bullets will automatically
Answers: 2
image
Computers and Technology, 25.06.2019 03:30, adrianVocke5685
Kou converged his word document to a powerpoint document. when he received the powerpoint, he was missing material. which most likely explains why the material was missing? a it did not have a proper heading b he incorrectly copied and pasted it c he did not save his document properly d there was not enough space in powerpoint
Answers: 1
Do you know the correct answer?
The numbers need to be read in as type double. the calculations need to be done using type double as...

Questions in other subjects:

Konu
Biology, 12.08.2020 05:01