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)<<Win dChillTemp (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;
}
#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)<<Win
}
}
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
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The error is:
C:\Documents and Settings\pro4b\pro4b\main. cpp(50) : error C2601: 'WindChillTemp' : local function definitions are illegal
C:\Documents and Settings\pro4b\pro4b\main.
ASKER
Never mind, I got it.
ASKER
Thank you!!!
You are most welcome.
ASKER
#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<<"*******************
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;
}