Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 189
  • Last Modified:

output into a table format

Below is a code that is supposed to print out a Wind Chill Temperature table for temperature values ranging from 30 °F down to -15 °F, in 5 degree decrements, and wind speeds ranging from 5 mph up to 35 mph, in 5 mile per hour increments.  I am having trouble getting the program to compute or read the values from the WindChillTemp function.  Help is much appreciated.

#include <iostream>
#include <string>
#include<complex>
#include<iomanip>
using namespace std;

double WindChillTemp (double t, double v)

{

double x = 35.74 + 0.6215 * t - 35.75 * pow(v,0.16) + 0.4275 * t * pow(v,0.16);

return x ;

}



int main(){
     double T,V;
double result;

cout<<"    ";

for (T=30; T >= -15 ; T -= 5)

     {

     cout<<T<<"\t";

     }

cout<<endl;

cout<<"*******************************************************************************";

cout<<endl;

for (V=5; V <= 35 ; V+=5)
cout<<V<<endl;


{
for(T=30; T >= -15 ; T -= 5);



 {for (V=5; V <= 35 ; V+=5)

 cout<<setprecision(2)<<WindChillTemp(T,V)<<"\t";
 }


}
cout<<endl;

 

 




//for(T = 30 ; T >= -15 ; T = T - 5)

//{  



//for (V = 5; V >= 35; V += 5)


//{

//result = WindChillTemp (T, V);

//cout<< result<<"/t";

//}



//}

return 0;

}




0
ktran40
Asked:
ktran40
  • 4
  • 2
1 Solution
 
ExceterCommented:
>> for(T=30; T >= -15 ; T -= 5);

This is a problem right here. Remove the semicolon.

Your function for finding the wind chill is fine. You can check it against this table,

http://www.usatoday.com/weather/resources/basics/windchill/wind-chill-chart.htm

double T,V;
double result;
cout << "\t";
for ( T = 30; T >= -15 ; T -= 5)
    cout << left << setw(7) << T;
cout<<endl;
cout<<"*******************************************************************************" << endl;
for (V=5; V <= 35 ; V+=5)
{
     cout << V << "\t";
     for( T = 30; T >= -15; T -= 5 )
          cout << left << setw(7) << setprecision(2) << WindChillTemp(T,V);
     cout << endl;
}
cout << endl;

double WindChillTemp (double t, double v)
{
     return 35.74 + 0.6215 * t - 35.75 * pow(v,0.16) + 0.4275 * t * pow(v,0.16);
}

Exceter
0
 
ktran40Author Commented:
Below is what I did with your suggestion.  I am getting 1 error 0 warnings.

#include <iostream>

#include <string>

#include<complex>

#include<iomanip>

using namespace std;



double WindChillTemp (double t, double v)

{

double x = 35.74 + 0.6215 * t - 35.75 * pow(v,0.16) + 0.4275 * t * pow(v,0.16);

return x ;

}



int main(){

double T,V;
double result;
cout << "\t";
for ( T = 30; T >= -15 ; T -= 5)
   cout << left << setw(7) << T;
cout<<endl;
cout<<"*******************************************************************************" << endl;
for (V=5; V <= 35 ; V+=5)
{
    cout << V << "\t";
    for( T = 30; T >= -15; T -= 5 )
         cout << left << setw(7) << setprecision(2) << WindChillTemp(T,V);
    cout << endl;
}
cout << endl;

double WindChillTemp (double t, double v)
{
    return 35.74 + 0.6215 * t - 35.75 * pow(v,0.16) + 0.4275 * t * pow(v,0.16);
}


 return 0;

}
0
 
ktran40Author Commented:
The error is:

C:\Documents and Settings\pro4b\pro4b\main.cpp(50) : error C2601: 'WindChillTemp' : local function definitions are illegal
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
ktran40Author Commented:
Never mind, I got it.  
0
 
ktran40Author Commented:
Thank you!!!
0
 
ExceterCommented:
You are most welcome.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 4
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now