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

C++ Program Write a program using structures to store the following weather info

ID: 3691176 • Letter: C

Question

C++ Program Write a program using structures to store the following weather information: •Total Rainfall •High Temperature •Low Temperature •Average Temperature Use an input file called input.txt to load the data to your array of 12 structures to hold the weather data (the average temperature should be calculated). Once the data for all the months is entered, the program should calculate and display the average monthly rainfall, total rainfall for the year, highest and lowest temps for the year (and the months they happen in) and the average of all the months average temperatures. Input temps should be between -100 and +140 and and total rainfall must not be less than 0 Output: Annual Rain Analysis Total Rain: 117.00 Average Rain: 9.75 Average of average rain: 49.50 The highest temp is: 102.00 in August The Lowest temp is: -30.00 in February

Input.txt:

Explanation / Answer

#include #include #include #include using namespace std; const int SIZE = 12; struct Weather {    double monthlyrainfall,highTemp,lowTemp,avgTemp; }; string month[SIZE]; char* monthstr(int i)     switch(i) {         case 0: return "JANUARY";         case 1: return "FEBRUARY";         case 2: return "MARCH";         case 3: return "APRIL";         case 4: return "MAY";         case 5: return "JUNE";         case 6: return "JULY";         case 7: return "AUGUST";         case 8: return "SEPTEMBER";         case 9: return "OCTOBER";         case 10: return "NOVEMBER";         case 11: return "DECEMBER";         default:         return " ";     } void getData(Weather[]); void calculate(Weather[], double&, double&, int&, int&); void display (Weather[],double, double , int, int); int main() {     double yearlyTotalRain =0,averageYearlyTemp=0; int yearliHITemp=0, yearlyLowTemp=0;     Weather wed[SIZE];     // populate the structure     getData(wed);     //calculate the yearly values     calculate(wed,yearlyTotalRain,averageYearlyTemp, yearliHITemp, yearlyLowTemp);     // display yearly values     display(wed,yearlyTotalRain,averageYearlyTemp, yearliHITemp, yearlyLowTemp);     return 0; } void getData(Weather w[]) {     ifstream fin("weather.txt");     if(!fin)     {         cout
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