double highTemp, lowTemp, lowAvg = 0, highAvg = 0; //Initialize these two
int count=0, freezDays;
string dayOfweek;
ifstream fin("weather.txt");
if(!fin) {
cout<<"Error opening file. Shutting down....\n";
return 0;}
while(fin>>dayOfweek)
{
fin>>highTemp;
fin>>lowTemp;
count++;
highAvg+=highTemp; // highAvg is a running total of all highTemps to date
lowAvg+=lowTemp;
}
if(count !=0) {
highAvg /= static_cast<double>(count); // Now divide it by count to actually make it an average.
lowAvg/= static_cast<double>(count);
cout<<"The average high tempeture was "<<highAvg<<endl;
cout<<"The average low tempeture was "<<lowAvg<<endl;
}