Question
Write a C++ programthat lets the user enter the total rainfall for each of the 12 months into an array of doubles . The program
Write a C++ programthat lets the user enter the total rainfall for each of the 12 months into an array of doubles. The program should calculate and display the total rainfall for the year, the average monthly rainfall, and the months with the highest and lowest amounts. Use main( ) as your driver function. Write main( ) so that it allows the user to run the program as many times as desired, as indicated by input from the user. Write functions that main( ) calls to accomplish the following tasks:
1.) Prompts and gets the total rainfall for each of the twelve months and stores these values in a one-dimensional array using a loop. Do not allow the user to enter a negative amount.
2.) Calculates the total rainfall for the year.
3.) Calculates the average rainfall for the year.
4.) Determines the largest amount of rainfall recorded for one month.
5.) Determines the smallest amount of rainfall recorded for one month.
6.) Displays the original rainfall amounts entered by the user for all twelve months using a loop, the total and average amount of rainfall for the year displayed to a hundredth of a decimal, and the amounts and month(s) that recorded the most and least amounts of rainfall.
Sample Input:
Enter the rainfall for month #1: 3.2
Enter the rainfall for month #2: 5.6
Enter the rainfall for month #3: 4.1
Enter the rainfall for month #4: 2.3
Enter the rainfall for month #5: 5.6
Enter the rainfall for month #6: 3.7
Enter the rainfall for month #7: 2.3
Enter the rainfall for month #8: 4.5
Enter the rainfall for month #9: 3.4
Enter the rainfall for month #10: 2.5
Enter the rainfall for month #11: 2.3
Enter the rainfall for month #12: 5.1
Sample Output:
The rainfalls for the following months were:
Month 1: 3.2
Month 2: 5.6
Month 3: 4.1
Month 4: 2.3
Month 5: 5.6
Month 6: 3.7
Month 7: 2.3
Month 8: 4.5
Month 9: 3.4
Month 10: 2.5
Month 11: 2.3
Month 12: 5.1
The total rainfall for the year was 44.60 inches.
The average rainfall for the year was 3.72 inches.
The month(s) that recorded the highest amount of rain of 5.60 inch(es) was (were):
Months #: 2 5
The month(s) that recorded the lowest amount of rain of 2.30 inch(es) was (were):
Months #: 4 7 11
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started