1. Design a Program that will that will record the weeks daily high and low temp
ID: 3622305 • Letter: 1
Question
1. Design a Program that will that will record the weeks daily high and low temperatures, calculate the average high temperature and the average low temperature.
2. There must either be two arrays, or one two dimensional array storing the week's daily high and low temperatures
3. This should repeat the entire program until the user requests to stop by inputting an N at the prompt.
4. Inputs
o Town Name including Spaces
o 7 Daily High and Low Temperatures
o Y/N for another week
5. Outputs
o Average Daily High Temperature which is the sum of all Daily High Temperatures / 7
o Average Daily Low Temperature which is the sum of all Daily Low Temperatures / 7
The Screen output should appear as follows:
I am using Dev C++ so make sure it complies. Make sure program fits the paramters and the output looks EXACTLY like the picture. Lifesaver given!
Explanation / Answer
please rate - thanks
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{string town;
int high[7],low[7],i,sum;
bool again=true;
char YorN;
while(again)
{cout<<"what is the name of the town? ";
getline(cin,town);
for(i=1;i<=7;i++)
{cout<<"What were the High and Low Temps for day "<<i<<"? ";
cin>>high[i-1];
cin>>low[i-1];
}
cout<<" Report of this Weeks Temperatures for "<<town<<endl;
for(i=1;i<=7;i++)
cout<<"Day "<<i<<" ";
cout<<endl;
for(i=0;i<7;i++)
cout<<high[i]<<" ";
cout<<"High Temperature ";
for(i=0;i<7;i++)
cout<<low[i]<<" ";
cout<<"Low Temperature ";
sum=0;
for(i=0;i<7;i++)
sum+=high[i];
cout<<" Average Daily High was "<<setprecision(3)<<fixed<<sum/7.<<" Degrees ";
sum=0;
for(i=0;i<7;i++)
sum+=low[i];
cout<<"Average Daily Low was "<<setprecision(3)<<fixed<<sum/7.<<" Degrees ";
cout<<"Would you like to enter another week (Y/N)? ";
cin>>YorN;
cin.ignore(80,' ');
if(toupper(YorN)=='N')
again=false;
}
return 0;
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.