Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ follow the prompt below Write a program that reads in the average monthly rainfall for a city for each month of the year and

C++ follow the prompt below

Write a program that reads in the average monthly rainfall for a city for each month of the year and then reads in the actual monthly rainfall for each of the previous 12 months. The program then prints out a nicely formatted table showing the rainfall for each of the previous 12 months as well as how much above or below average the rainfall was for each month. The average monthly rainfall is given for the months January, February, and so forth, in order. To obtain the actual rainfall for the previous 12 months, the program first asks what the current month is and then asks for the rainfall figures for the previous 12 months. The output should correctly label the months.

There are a variety of ways to deal with the month names. One straightforward method is to code the months as integers and then do a conversion before doing the output. A large switch statement is acceptable in an output function. The month input can be handled in any manner you wish, as long as it is relatively easy and pleasant for the user.

After you have completed this program, produce an enhanced version that also outputs a graph showing the average rainfall and the actual rainfall for each of the previous 12 months. There should be two bar graphs for each month and they should be labeled as the average rainfall and the rainfall for the most recent month. Your program should ask the user whether she or he wants to see the table or the bar graph and then should display whichever format is requested. Include a loop that allows the user to see either format as often as the user wishes until the user requests that the program end.

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

image text in transcribed

//Enhanced version: 1/Add capability to print the bar graphs for each month, 1/ showing the average rainfall and the actual rainfall for //each of the previous 12 months. Ask the user's preference: 1/2 table or a graph, and display the format requested. 1/Provide a loop to repeat the process at the user's request. #include #include #include struct monthly_rain 1 int month; double rain_fall; double avg_rain_fall; //declaration of function from file C10Prgi bargraph.cpp void output_bargraph monthly rain rainfallt, int current_month); 1/output: scale and bargraph of month by month average and 1/actual rainfall void input ( monthly_rain rainfa11[], int year); //precondition: 1/routine called correctly, with variable arguments //postcondition: //User is asked for current month, then is asked for / /the average and actual rainfall for each of the //preceding 12 months. void output_table monthly_rain rainfall[], ints year); //Precondition: 1/input is array of size 12 of monthly_rain structs. 1/Postcondition: output to screen is formatted table showing //rainfall for each of the previous 12 months as well as how //much above or below the monthly average the rainfall //for each month. The output should correctly label months. int main() { using namespace std; int current month: //Enhanced version: 1/Add capability to print the bar graphs for each month, 1/ showing the average rainfall and the actual rainfall for //each of the previous 12 months. Ask the user's preference: 1/2 table or a graph, and display the format requested. 1/Provide a loop to repeat the process at the user's request. #include #include #include struct monthly_rain 1 int month; double rain_fall; double avg_rain_fall; //declaration of function from file C10Prgi bargraph.cpp void output_bargraph monthly rain rainfallt, int current_month); 1/output: scale and bargraph of month by month average and 1/actual rainfall void input ( monthly_rain rainfa11[], int year); //precondition: 1/routine called correctly, with variable arguments //postcondition: //User is asked for current month, then is asked for / /the average and actual rainfall for each of the //preceding 12 months. void output_table monthly_rain rainfall[], ints year); //Precondition: 1/input is array of size 12 of monthly_rain structs. 1/Postcondition: output to screen is formatted table showing //rainfall for each of the previous 12 months as well as how //much above or below the monthly average the rainfall //for each month. The output should correctly label months. int main() { using namespace std; int current month

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

Step: 3

blur-text-image

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

Modern Database Management

Authors: Jeffrey A. Hoffer Fred R. McFadden

9th Edition

B01JXPZ7AK, 9780805360479

More Books

Students also viewed these Databases questions

Question

What are the objectives of Human resource planning ?

Answered: 1 week ago

Question

Explain the process of Human Resource Planning.

Answered: 1 week ago

Question

2 What are the implications for logistics strategy?

Answered: 1 week ago