Assignment #7

advertisement
CS 1700
Cannon
Intro to Computer Science
Spring 2006
Assignment #7
Write and test a program to generate a text report file containing a summary of snow depths over a 12month period. For each month, the program should prompt the user for the number of snow depth
measurements made during the month and then prompt for each of these measurements. Assume every
month will have at least one measurement, although a measurement value can be zero (August?). The
console interface should appear as in the following example. Here, the example values entered by the user
have been underlined:
SNOW DEPTH SUMMARY
Month 1: Enter number of measurements: 3
Enter measurement: 67
Enter measurement: 72
Enter measurement: 83
Month 2: Enter number of measurements: 2
Enter measurement: 85
Enter measurement: 92
Month 3: Enter number of measurements: 6
Enter measurement: 83
Enter measurement: 72
Enter measurement: 58
Enter measurement: 41
Enter measurement: 44
Enter measurement: 36
…
And so on for a full 12 months. The text report file should be named snow_depth.txt and contain a
summary. For example – showing just the first 3 months using the above input:
SNOW DEPTH SUMMARY REPORT
Month 1: 3 measurements, average snow depth 74.00 inches
Month 2: 2 measurements, average snow depth 88.50 inches
Month 3: 6 measurements, average snow depth 55.67 inches
…
CHALLENGE: Have your program also output the average snow depth for each two month period. For
example, the average for months 1 and 2, the average for months 2 and 3, the average for months 3 and 4,
and so on.
EXTRA CHALLENGE: Have your program automatically print today’s date at the top of the report. This
should be done automatically without any additional user input.
Download