Question: Your code works, but I have to follow a template and I am not able to attach the template here. Can I email the template?

Your code works, but I have to follow a template and IYour code works, but I have to follow a template and I am not able to attach the template here. Can I email the template? For this assignment.

//Provide a loop to repeat the process at the user's request.

#include #include #include

struct monthly_rain { int month; double rain_fall; double avg_rain_fall; };

//declaration of function from file Ch10Prg1.bargraph.cpp void output_bargraph( monthly_rain rainfall[], int current_month ); //output: scale and bargraph of month by month average and //actual rainfall.

void input( monthly_rain rainfall[], int& year ); //precondition: //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[], int& year ); //Precondition: //input is array of size 12 of monthly_rain structs. //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; monthly_rain rainfall[12]; char ans; char tg; do { input( rainfall, current_month); cout > tg; //tg means table/graphics choice :)

if ( 't' == tg || 'T' == tg ) { cout > ans; }while( 'y' == ans || 'Y' == ans ); return 0; }

void full_month_name(int);

void input( //Complete the argument list) { // Complete the function cout

cout

cout

cout

cout

cout

//helping routines for output_table, defined at the end of //this file. void month_name( int month ); void full_month_name( int month);

void output_table(//Complete the argument list) { // Complete the function using namespace std; int i; cout.setf(ios::fixed); cout.setf(ios::showpoint); cout.precision(1); //heading: Monthly Rainfall // For the 12 Months Preceding ..... // Actual, Average, and Difference (= Actual - Average)

}

void month_name( int month ) { // Complete the function switch (month) { } }

void full_month_name( int month ) { // Complete the function switch (month) { }

// //to print two bargraphs for each month, showing average and //actual rainfall each month.

void full_month_name( int ); void month_name( int );

//outputs x asterisks, no void bargraph( double x ) { // Complete the function }

//output scale followed by // void output_scale() { using namespace std; cout

void output_bargraph( //Complete the argument list ) { // Complete the function }

/* There follows edited output obtained from this run.

Monthly rainfall input routine.

Please enter the average rainfall for each month Average rainfall: For month January Avg Rainfall: 3.7 For month February Avg Rainfall: 3.6 For month March Avg Rainfall: 5.1 For month April Avg Rainfall: 3.8 For month May Avg Rainfall: 4.2 For month June Avg Rainfall: 4.2 For month July Avg Rainfall: 4.4 For month August Avg Rainfall: 4.8 For month September Avg Rainfall: 4 For month October Avg Rainfall: 3.3 For month November Avg Rainfall: 3.3 For month December Avg Rainfall: 3.5

The actual rainfall: What is the current month? Please give the number of the month (Jan = 0, etc. The current month is: May Please enter the actual rainfall for each month, as prompted, First for the months in the previous year: For month May Rainfall: 4.3 For month June Rainfall: 3.2 For month July Rainfall: 5.5 For month August Rainfall: 5.1 For month September Rainfall: 4 For month October Rainfall: 2.2 For month November Rainfall: 2 For month December Rainfall: 1.1 Now for the months in this year: For month January Rainfall: 4.1 For month February Rainfall: 3.3 For month March Rainfall: 3.9 For month April Rainfall: 3.7 Please choose between g)raphical and t)abular output You chose the tabular output. Monthly Rainfall For the 12 Months Preceding May Actual, Average, and Difference (= Actual - Average) -----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+---- Jan | Feb | Mar | Apr | May | Jun | Jul | Aug | Sep | Oct | Nov | Dec -----+-----+-----+-----+-----+-----+-----+-----+-----+-----+-----+---- average 4.1 | 3.3 | 3.9 | 3.7 | 4.3 | 3.2 | 5.5 | 5.1 | 4.0 | 2.2 | 2.0 | 1.1 actual 3.7 | 3.6 | 5.1 | 3.8 | 4.2 | 4.2 | 4.4 | 4.8 | 4.0 | 3.3 | 3.3 | 3.5 diffs 0.4 |-0.3 |-1.2 |-0.1 | 0.1 |-1.0 | 1.1 | 0.3 | 0.0 |-1.1 |-1.3 |-2.4 P)rev yr | | | | P | P | P | P | P | P | P | P

Y/y continues, any thing else quits Monthly rainfall input routine.

Please enter the average rainfall for each month Average rainfall: For month January Avg Rainfall: 3.7 . . . . For month December Avg Rainfall: 3.5

The actual rainfall: What is the current month? Please give the number of the month (Jan = 0, etc. The current month is: May Please enter the actual rainfall for each month, as prompted, First for the months in the previous year: For month May Rainfall: 4.3 . . . . For month December Rainfall: 1.1 Now for the months in this year: For month January Rainfall: 4.1 . . . . For month April Rainfall: 3.7 Please choose between g)raphical and t)abular output You chose the graphical output

Rainfall 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 |****|****|****|****|****|****|****|****|****|****|****|****|****|**** January average ************************************** actual ***************************************** February average ************************************* actual ********************************* March average *************************************************** actual *************************************** April average ************************************** actual ************************************** May (Previous year) average ******************************************* actual ******************************************* June (Previous year) average ******************************************* actual *********************************

Rainfall 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 |****|****|****|****|****|****|****|****|****|****|****|****|****|**** July (Previous year) average ********************************************* actual ******************************************************* August (Previous year) average ************************************************ actual *************************************************** September(Previous year) average **************************************** actual **************************************** October (Previous year) average ********************************* actual *********************** November(Previous year) average ********************************* actual ******************** December(Previous year) average *********************************** actual ************

Rainfall 0.0 0.5 1.0 1.5 2.0 2.5 3.0 3.5 4.0 4.5 5.0 5.5 6.0 6.5 |****|****|****|****|****|****|****|****|****|****|****|****|****|**** Y/y continues, any thing else quits */

1. 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. The graph should be similar to the one shown in Display 7.8, except that 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. 1. 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. The graph should be similar to the one shown in Display 7.8, except that 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

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!