Link to home
Start Free TrialLog in
Avatar of ktran40
ktran40

asked on

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;

}




ASKER CERTIFIED SOLUTION
Avatar of Exceter
Exceter
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of ktran40
ktran40

ASKER

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;

}
Avatar of ktran40

ASKER

The error is:

C:\Documents and Settings\pro4b\pro4b\main.cpp(50) : error C2601: 'WindChillTemp' : local function definitions are illegal
Avatar of ktran40

ASKER

Never mind, I got it.  
Avatar of ktran40

ASKER

Thank you!!!
You are most welcome.