Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am trying to get each monthly temp average temperature to display..for instanc

ID: 3529070 • Letter: I

Question

I am trying to get each monthly temp average temperature to display..for instance //chapter 11 program #include#includeusing namespace std; enum Month{January,February,March,April,May,June,July,August,September,October,November,December}; struct WeatherData { double Total_Rainfall; double High_Temperature; double Low_Temperature; double Average_Temperature; }; const int Num_of_Months = 12; WeatherData arrayStruct[Num_of_Months]; void displayMonthName(Month); double averageMonthlyTemperature = 0.0; double averageMonthlyRainfall = 0.0; double highestTemperature = -100.0; double lowestTemperature = 140.0; double totalyearlyRainfall = 0.0; Month highest; Month lowest; int main() { //given high and low temps calculate average //for each month //use the enumeratation Month index; //initialize the position by type //reading data for months for(index = January; index <= May; index = static_cast(index+1)) // incrementing months { cout<<"Enter total rainfall for "; displayMonthName(index); // function call to print a month cout << ": "; //print colon and space cin>>arrayStruct[index].Total_Rainfall; cout<<"Enter high temperature for "; displayMonthName(index); // function call to print the month cout << ": "; //print colon and space cin>>arrayStruct[index].High_Temperature; while(arrayStruct[index].High_Temperature < -100 || arrayStruct[index].High_Temperature > 140) { cout<< "High Temperature is invalid"<<endl; cout<< "Enter valid High Temperature between -100 and 140"<<endl; cin>> arrayStruct[index].High_Temperature; } cout<<"Enter low temperature for "; displayMonthName(index); // function call to print the month cout << ": "; //print colon and space cin>>arrayStruct[index].Low_Temperature; while(arrayStruct[index].Low_Temperature < -100 || arrayStruct[index].Low_Temperature > 140) { cout<< "Low Temperature is invalid"<<endl; cout<< " Enter valid Low Temperature between -100 and 140"<<endl; cin>> arrayStruct[index].Low_Temperature; } // calculater average temp arrayStruct[index].Average_Temperature = (arrayStruct[index].High_Temperature + arrayStruct[index].Low_Temperature)/2; cout<<"averageMonthTemperature"; displayMonthName(index); cout<< " : "; cin>>arrayStruct[index].Average_Temperature; } // calculating values for month for(index = January; index <= May; index = static_cast(index+1)) //incrementing months { totalyearlyRainfall += arrayStruct[index].Total_Rainfall; averageMonthlyRainfall += (arrayStruct[index].Total_Rainfall) / 12; averageMonthlyTemperature += (arrayStruct[index].Average_Temperature) / 12; if(arrayStruct[index].High_Temperature > highestTemperature) // if highest monthly temperatere is greater than year, change it to highest yearly temp { highestTemperature = arrayStruct[index].High_Temperature; // highest yearly temp is equal to highest monthly temperature highest = index; //hightest temperate of the the year equals the current month.. (highest -yeal) index (month) } if(arrayStruct[index].Low_Temperature < lowestTemperature) { lowestTemperature = arrayStruct[index].Low_Temperature; // lowest yearly temp is equal to lowest monthly temperature lowest = index; //lowest temperate of the the year equals the current month.. (lowest -yeal) index (month) } } // display all variables cout << "The average monthly temperature is "<<averageMonthlyTemperature<<endl; cout << "The average monthly rainfall is "<<averageMonthlyRainfall<<endl; cout << "The highest temperature is "<<highestTemperature << ", which occurred in "; displayMonthName(highest); // display month that had the highest temperature cout << " The lowest temperature is "<<lowestTemperature << ", which occurred in "; displayMonthName(lowest); // display month that had the lowest temperature cout << " The total yearly rainfall is "<<totalyearlyRainfall<<endl; return 0; } // define function prototype displayMonthName void displayMonthName(Month m) //determine which month to display { switch (m) //how program will branch from one month to the next month enum type of (M) { case January: // expression cout<<"January"; // print January break; case February: cout<<"February"; break; case March: cout<<"March"; break; case April: cout<<"April"; break; case May: cout<<"May"; break; case June: cout<<"June"; break; case July: cout<<"July"; break; case August: cout<<"August"; break; case September: cout<<"September"; break; case October: cout<<"October"; break; case November: cout<<"November"; break; case December: cout<<"December"; break; } }

Explanation / Answer

// This program takes rainfall statistics and displays the total for a year, average monthly rainfall, and highest and lowest amounts. // 7.2 Programming Challenge #include #include using namespace std; // Constant for number of months const int numMonths = 12; //Function Prototypes double getTotal(double []); double getAverage(double []); double getHighest(double [], int &); double getLowest(double [], int &); int main () { // Array for holding the rainfall amounts double rainFall[numMonths]; // Get rainfall for each month. for (int month = 0; month
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote