Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1) Write a C++ program that lets the user enter the total rainfall for each of the 12 months into an array of doubles .

1) Write a C++ program that 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:

a) 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.

b) Calculates the total rainfall for the year.

c) Calculates the average rainfall for the year.

d) Determines the largest amount of rainfall recorded for one month.

e) Determines the smallest amount of rainfall recorded for one month.

f) 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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Joy L. Starks, Philip J. Pratt, Mary Z. Last

9th Edition

1337093424, 978-1337093422

Students also viewed these Databases questions

Question

What was unique about SAPs first ERP system?

Answered: 1 week ago