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 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
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
//output scale followed by 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 */
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
