Java: Programming - Rainfall Stats

Write a program to print rainfall statistics for one week

This program will read a series of seven rainfall measurements (integer number of millimeters of rain, one each of the seven days). It will then print the following statistics.

Sample data and results

Sample input data

Here are some sample values. Of course, it should work for any values.

1
0
12
7
0
0
11

Sample output

Maximum rainfall = 12, Average rainfall = 4.428571428571429

You may format the output differently if you wish.

Some hints

Iterative approach

As with all programs, you should use an iterative approach. Exactly how much you do in every step is not so important as to take small steps, and get each one running before continuing. You might do something like the following.

  1. Start with a program that does nothing!
  2. Read one number and display it.
  3. Write a loop to read and display 7 numbers (but no computation).
  4. Create a variable for the sum of all rainfall, initialize it, and add all the input values. Print at the end.
  5. Keep track of the maximum.
  6. You're done!

Extra (cancellation) Credit

If you have the program running, you can go for "cancellation" credit. You can't get more than full credit, but this can cancel out any other points off in the problem.