Hi Sariss1990
At the end of the second for loop, you have a ';' that will prevent that loop from actually being of any use: for (int temperature = 45; temperature >= -10; temperature -= 5);
If you remove the ; you will then be able to use the temperature variable, which is what I presume the 't' variable is supposed to be refering to, and is the second problem.
Currently the 's' and 't' variables that you are using to calculate windChill are never given a value, so the computer gives them a default value that isn't any use. You can either assign the values of windSpeed and temperature to s and t inside the for loops, e.g.: s = windSpeed; t = temperature; or more simply use windSpeed and temperature in the calculation to make it clearer.
Finally, I'm guessing from your question that you want the windChill data to be printed out like the table at the top? At the moment, the use of endl in the inner for-loop will cause each entry to be printed on a new line, e.g. cout << endl;. Alternatively, you could print a new line in the outer for loop, so that all the data from the inner for loop stayed on the same line. To get it looking just like the table above, you may need to play around with some conditions.
Well I have the code to where it says there are no errors in it, but it still doesn't look like the windchill table it's supposed to look like. Here's my new code:
#include <iostream>
#include <cmath>
#include <iomanip>
using namespace std;
int main()
{
int windChill;
cout << "Wind Chill Index Table" << endl;
cout << " | Temperature" << endl;
cout << "MPH" << endl;
int windSpeed = 5;
for (windSpeed = 5; windSpeed <= 50; windSpeed += 5) // Generate wind speeds $
{
int temperature = 45;
for (temperature = 45; temperature >= -10; temperature -= 5) // Generate tem$
{
int temperature, windSpeed;
double windChill = round(35.74 + 0.6215 * temperature - 35.75 * pow(windSpee$
cout << setw(5) << windChill;
}
}
return 0;
}
Here's what it looks like when I run the program:
Wind Chill Index Table
| Temperature
MPH
5.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+095.8201e+09