Hi i'm currently working on a problem I got in my Highschool C++ class.
Were supposed to write a program which contains arrays in which you can store the highest monthly temperature and the lowest. And also, the program should have a loops to calculate each of the following:
Yearly Average High Temperature
Yearly Average Low Temperature
Highest Monthly Average High Temperature
- Lowest Monthly Average High Temperature
I'm stuck with the monthly highest and lowest average temperature and could need some help. My code so far is:
#include <iostream>
using namespace std;
int main()
{
class location;
int high[12];
int low[12];
int i = 1;
int avgh, avgl;
//set location
std::string location;
std::cout << "Where is the location of your data: ";
std::getline(std::cin, location);
cout << endl << endl;
//initialize array high
for (i = 1; i < 13; i++)
{
cout << "Enter temperature high of month " << i << " ";
cin >> high[i];
avgh += high[i];
}
cout << endl << endl;
//initialize array low
for (i = 1; i < 13; i++)
{
cout << "Enter temperature low of month " << i << " ";
cin >> low[i];
}
cout << endl << endl;
//adds highs together
for (i = 1; i < 13; i++)
{
avgh += high[i];
}
cout << "The yearly average high is: " << avgh/12 << endl;
//adds lows together
for (i = 1; i < 13; i++)
{
avgl += low[i];
}
cout << "The yearly average low is: " << avgl/12 << endl;
return 0;
}