The purpose of this exercise is to train you to use simple loops and conditional statements.
Estimated workload of this exercise is 20 min.
Please, proceed to Average class and write a program that reads a sequence of integer values from standard input and finds the average value.
Details:
- You must read sequence values until the next one is
0. Zero value means end of the input sequence. - The sequence is guaranteed to contain at least one value.
- Average value is also an integer. Use integer operations.
Input: 1 2 3 4 5 0
Output: 3
Input: 1 2 3 4 6 0
Output: 3
Input: 1 2 3 4 0
Output: 2
Input: 1 1 9 0
Output: 3