Objective
- Program with repetition statements
Preparation
- Read section 5.1 - 5.10 (pages 227 - 264) from Starting Out with C++ by Gattis.
- Print and complete Worksheet 9.
Programming
- Write a program that will read from the standard input device a sequence of integer values in the range of 1 through 10. The program should quit reading the sequence of values when a sentinel value of 0 is input. So, it is valid for the user to input 0 or 1-10. The program should validate the input. Display the count, minimum, maximum, and average of the entered values. You do not need to modularize your program nor should you. Format your user interaction to look just like the following example:
Enter an integer (0 to quit): 4
Enter another integer (0 to quit): 7
Enter another integer (0 to quit): 8
Enter another integer (0 to quit): 2
Enter another integer (0 to quit): 5
Enter another integer (0 to quit): 0
Count Min Max Average
5 2 8 5.20
- (Optional) Extend your program to be able to repeat so that multiple sequences are input. After displaying the statistics for a sequence, ask the user if she/he wants to do another sequence.
- Verify the program works correctly.
- Print the Grade Sheet. Show your program to the instructor.
|