Phew, after your guys help and even more research, i got everything to work.
Wasn't aware that you could declare variables inside of for loops and other functions, that was an eye opener for sure. made everything else fall into place.
My question now, is I have recreated the table perfectly (aside from two of the values rounding higher, which I'm going to chalk up to math since the rest of them came out perfectly). Is there a way to put the actual temperature values and wind speed values as the x and y axis, that way the person looking at my table would actually know what they are looking at??
I tried to manual enter them via cout<< but nothing lined up correctly.
My updated code is below.
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
|
#include <iostream>
#include <math.h>
#include <iomanip>
using namespace std;
const int TEMPS = 18;
const int WINDS = 12;
int main () {
double windChill[TEMPS][WINDS] = {0};
for (int j=0; j<WINDS; ++j) {
for (int i=0; i<TEMPS; ++i) {
int temp = 40 - i*5;
int wind = 5 + j*5;
windChill[i][j] = round (35.74 + (.6215 * temp) - ((35.76) * (pow(wind, .16)))
+ ((.4275 * temp) * (pow(wind, .16))));
}
}
for (int j=0; j<WINDS; ++j) {
for (int i=0; i<TEMPS; ++i) {
cout << setw (4);
cout << windChill[i][j]; //two numbers different outputs, rounding?
}
cout << "\n";
}
cout << "test line\n";
return 0;
}
|
Again, any help is appreciated. I don't need to be told the answer, just pointed in the right direction! Thanks