简体   繁体   中英

Calculating Nested for-loops in organized fashion

The wind chill index combines the temperature and wind speed to tell us how cold the wind makes it "feel." The new wind chill index (often called the “wind chill factor”) used by the US and Canadian weather services is determined by iterating a model of skin temperature under various wind speeds and temperatures. The results of this model may be approximated, to within one degree, from the following formula. windchill = round(35.74 + 0.6215 * T – 35.75 * S 0.16 + 0.4275 * T * S 0.16) Where T is the temperature in degrees Fahrenheit, and S is the wind speed in miles per hour. Write a program that will produce the following wind chill table. You must use a nested loop.

What am I doing wrong?

I am coming back with errors back to back to back. Thank you!

Wind Chill Table
Speed Temperature T
MPH 45 40 35 30 25 20 15 10 5 0 -5 -10
-----------------------------------------------------------
 5 | 42 36 31 25 19 13 7 1 -5 -11 -16 -22
10 | 40 34 27 21 15 9 3 -4 -10 -16 -22 -28
15 | 38 32 25 19 13 6 0 -7 -13 -19 -26 -32
20 | 37 30 24 17 11 4 -2 -9 -15 -22 -29 -35
25 | 36 29 23 16 9 3 -4 -11 -17 -24 -31 -37
30 | 35 28 22 15 8 1 -5 -12 -19 -26 -33 -39
35 | 35 28 21 14 7 0 -7 -14 -21 -27 -34 -41
40 | 34 27 20 13 6 -1 -8 -15 -22 -29 -36 -43
45 | 33 26 19 12 5 -2 -9 -16 -23 -30 -37 -44
50 | 33 26 19 12 4 -3 -10 -17 -24 -31 -38 -45
-----------------------------------------------------------
#include <iostream>
#include <cmath>
#include <iomanip>

int main()
{
int t;
int s;
  int windchill;
  //cout << setw(5) << x;

  //YOUR CODE: output the table heading (top 4 rows of table) with separate     cout stm$


//YOUR CODE: Two nested for-loops to generate speed S= 5, 10, ...,50 and
// temperature T = 45, 40, ..., -10
//in the innermost loop the windchill should be calculated and displayed

 for(t=50;t<=-10;t-5)
{

windchill = round(35.74+0.6215*t-35.75*pow(s,0.16)+0.4275*t*pow(s,0.16));

 cout << windchill;
    for(s=0;s>=50;s+5)
   {
   cout << s;


   }

}
return 0;
}

If 'cout' was not declared in this scope is the only error, your fix is here.

Add using namespace std; to the beginning of your file (after includes) or use std::cout instead of cout .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM