//Andrew Alspaugh CS1A Chapter 11. P.646. #4
//
/*****************************************************************************
Store Weather Statistcs
____________________________________________________________________________
This program does blah blah blah with weather statistics displays a bunch of
random numbers
____________________________________________________________________________
//Data Dictionary
//Inputs
const int months = 12;
Weather weather[months];
//Outputs
float totalRain = 0.0;
float averageRain;
float totalAvgTemp = 0.0;
float highestTemp = -1000.0; // initial value very low
int highMonth = 0;
float lowestTemp = 1000.0; // initial value very high
int lowMonth = 0;
*****************************************************************************/
#include <iostream>
using namespace std;
struct Weather
{
float rainfall;
float highTemp;
float lowTemp;
float aver;
};
int main()
{
//Data Dictionary
//Inputs
const int months = 12;
Weather weather[months];
//Outputs
float totalRain = 0.0;
float averageRain;
float totalAvgTemp = 0.0;
float highestTemp = -1000.0; // initial value very low
int highMonth = 0;
float lowestTemp = 1000.0; // initial value very high
int lowMonth = 0;
//INPUT
for(int i = 0; i < months; i++)
{
cout << "Enter Rainfall for Month " << i + 1 << " :" << endl;
cin >> weather[i].rainfall;
cout << "Enter Highest Temperature for Month " << i + 1 << " :" << endl;
cin >> weather[i].highTemp;
cout << "Enter Lowest Temperature for Month " << i + 1 << " :" << endl;
cin >> weather[i].lowTemp;
weather[i].aver = (weather[i].highTemp + weather[i].lowTemp) / 2.0;
totalRain += weather[i].rainfall;
totalAvgTemp += weather[i].aver;
if(weather[i].highTemp > highestTemp)
{
highestTemp = weather[i].highTemp;
highMonth = i + 1;
}
if(weather[i].lowTemp < lowestTemp)
{
lowestTemp = weather[i].lowTemp;
lowMonth = i + 1;
}
}
//PROCESS
averageRain = totalRain / months;
float overallAvgTemp = totalAvgTemp / months;
//OUTPUT
cout << "Total Rainfall for the year: " << totalRain << endl;
cout << "Average Monthly Rainfall: " << averageRain << endl;
cout << "Highest Temperature of the year: " << highestTemp << " in month " << highMonth << endl;
cout << "Lowest Temperature of the year: " << lowestTemp << " in month " << lowMonth << endl;
cout << "Average of all monthly average temperatures: " << overallAvgTemp << endl;
return 0;
}