1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112
|
#include <iostream>
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
const int MAX=7;
int highs[MAX];
int lows [MAX];
int diff [MAX];
char month[80];
char day[80];
char year[80];
char days_of_week [MAX][15] = {"Monday ","Tuesday ", "Wednesday", "Thursday ", "Friday ", "Saturday ", "Sunday "};
char str[80];
char str2[80];
char str3[80];
int avg_high;
int avg_low;
int x;
cout << "Please enter the 7 high temperatures of the week: " << "\n";
for (x=0; x<MAX; x++) {
highs[x]=x;
cin >> highs[x];
}
cout << "\n";
cout << "Please enter the 7 low temperatures of the week: " << "\n";
for (x=0; x<MAX; x++){
lows[x]=x;
cin >> lows[x];
}
for (x=0; x<MAX; x++){
diff[x]=highs[x]-lows[x];
}
gets_s(month);
cout << "\n";
cout << "Please enter the month we are currently in: ";
gets_s(month);
cout << "\n";
cout << "Please enter the numerical day we are currently in: ";
gets_s(day);
cout << "\n";
cout << "Please enter the year we are currently in: ";
gets_s(year);
cout << "\n";
strcpy_s (str, month);
strcpy_s (str2, day);
strcpy_s (str3, year);
strcat_s (str2, ", ");
strcat_s (str2, str3);
strcat_s (str, " ");
strcat_s (str, str2);
cout << "\t" << str;
cout << "\n\n";
cout << "Day" << "\t\t" << "High" << "\t" << "Low" << "\t" << "Difference \n";
for (x=0; x<MAX; x++){
cout << days_of_week[x] << "\t";
cout << highs[x] << "\t";
cout <<" " << lows[x] << "\t";
cout <<" " << diff[x] << "\n" ;
}
cout << "\n";
cout << "High for the week: 92 \t";
cout << "Low for the week: 55 \n";
avg_high=0;
for (int n=0; n<MAX; n++){
avg_high+= highs[n];
}
avg_high /= MAX;
cout << "The average high is " << avg_high << "\t";
avg_low=0;
for (int i=0; i<MAX; i++){
avg_low+= lows[i];
}
avg_low /= MAX;
cout << "The average low is " << avg_low << "\n";
system ("pause");
return 0;
}
|