//Sam Trivikraman CS1A Chapter 11, p. 646, #4
//
/*
******************************************************************************
Store Weather Stats
_______________________________________________________________________________
This program stores the total fainfall, highest temperatures, lowest temperatures,
and average temperatures for each month of the year.
_______________________________________________________________________________
INPUT
total rainfall : The total inches of rainfall for the month
highest temperature : The highest temperature for the month
lowest temperature : The lowest temperature for the month
average temperature : The average temperature for the month
OUTPUT
array of weather stats : An array that stores all of the details for the weather for the year
_______________________________________________________________________________
*******************************************************************************
*/
#include <iostream>
using namespace std;
//structure that stores the weather stats
struct weather
{
int totalRain; //INPUT The total inches of rainfall for the month
int highTemp; //INPUT The highest temperature for the month
int lowTemp; //INPUT The lowest temperature for the month
int avgTemp; //INPUT The average temperature for the month
};
int main() {
weather info[12]; //OUTPUT An array that stores all of the details for the weather for the year
int rain; //OUTPUT the total amount of rain for a year
int highest = 0; //OUTPUT the highest temperature for the year
int lowest = 140; //OUTPUT the lowest temperature for the year
int average; //OUTPUT the average temperature for the year
//ask the user for the inches of rain per month, highest temp, lowest temp
//calculate the total amount of rain for the year
for(int i = 0; i < 12; i++)
{
cout << "Please enter the total inches of rain" << endl;
cin >> info[i].totalRain;
rain += info[i].totalRain;
cout << "Please enter the highest temperature from this month" << endl;
cin >> info[i].highTemp;
if(info[i].highTemp > highest)
{
highest = info[i].highTemp;
}
cout << "Please enter the lowest temperature from this month" << endl;
cin >> info[i].lowTemp;
if(info[i].lowTemp < lowest)
{
lowest = info[i].lowTemp;
}
}
//Output total monthly rainfall, highest and lowest temps
cout << "The total monthly rainfall is: " << rain << " inches." << endl;
cout << "The highest temperature is: " << highest << " degrees." << endl;
cout << "The lowest temperature is: " << lowest << " degrees." << endl;
return 0;
}