Computer Science Using C++
Ch. 14 Programming Assignment Part II
Write a C++ program that reads nine integer values from 9
separate lines of an external text file named Ch14Proj2data.txt.
(See the hyperlink for an example of this text file.) The file is located
in the same folder as your source file. As soon as the program reads the
first three values, it should compute and display the average of those three
values. After reading the sixth value, it should display the average of
the second set of three integers. It should display the average of the last
three integers after reading them. Finally, the program must also display
the overall average value of all nine values with a suitable message. All
averages must be displayed in fixed notation rounded (not truncated)
to the nearest hundredth's place. Use one or more loops in this program
so that it can be easily upgraded if more than 9 integers were placed
in the text file. Therefore, you must use very careful design for this assignment
in order to receive a high grade. Avoid using brute force! You must also
store the values into an apvector as they are read from the file.
Preconditions:
Your program must follow the Wyo Area
Comp Sci Documentation & Coding Standards. Place a copy of Ch14Proj2.cpp
in your Submit folder so that the instructor can execute your program within
that folder. Also place a copy of the text file, Ch14Proj2data.txt
Here is an example test plan item:
Possible Inputs |
Expected Output |
Reason for Test Item |
|||||
values from text file |
first ave
|
second ave
|
third ave
|
overall ave
|
|
||
1. | 1, 2, 3, 4, 5, 6, 7, 8, 9 | 2 | 5 | 8 | 5 | normal case |
Computer Science Using C++ Home Page | Mr. Minich's Wyo Home Page