Hi,
I did the following code. It can be run except one point that I do not know how to handle it.
How can I get the total of temperature for EACH day? I got the figure to be 30 for these 5 days.
Thanks for help.
gogo
#include <iostream>
#include <string>
#include <cctype>
#include <iomanip>
using namespace std;
int main()
{
const int x = 5;
const int y = 3;
const string week[] = {"Mon", "Tue", "Wed", "Thu", "Fri"};
float day[x][y] = {0};
float average[y] = {0};
float sum = 0;
float sum1 =0;
int count = 0;
for (int i=0; i<x; i++)
{
cout << endl;
for (int j=0; j<y; j++)
{
cout << "Pls enter " << week[i] << "\'s temperature ";
cout << "with reading #" << (j+1) << " :";
cin >> day[i][j];
}
}
cout << endl;
for (int a=0; a<y; a++)
for (int b=0; b<x; b++)
average[a] += day[b][a];
cout << "Average morning temp is " << average[0]/x << "." << endl;
cout << "Average afternoon temp is " << average[1]/x << "." << endl;
cout << "Average evening temp is " << average[2]/x << "." << endl;
cout << endl;
for (int e=0; e<x; e++)
{
cout << week[e] << endl;
for (int f=0; f<y; f++)
{
cout << "reading # " << (f+1) << "is : " << day[e][f] << endl;
count = count++;
sum += day[e][f];
sum1 += day[0][f]; //Don't understand??
}
cout << endl;
}
cout << "Total 1-5 = " << sum << endl << endl;
for (int g=0; g<x; g++)
cout << week[g] << "\'s total is " << sum1 << endl << endl;
return 0;
}