?
Solved

output into a table format

Posted on 2003-02-18
6
Medium Priority
?
187 Views
Last Modified: 2010-04-01
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
Comment
Question by:ktran40
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 2
6 Comments
 
LVL 8

Accepted Solution

by:
Exceter earned 200 total points
ID: 7979287
>> 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
 

Author Comment

by:ktran40
ID: 7981242
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
 

Author Comment

by:ktran40
ID: 7981260
The error is:

C:\Documents and Settings\pro4b\pro4b\main.cpp(50) : error C2601: 'WindChillTemp' : local function definitions are illegal
0
Independent Software Vendors: 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!

 

Author Comment

by:ktran40
ID: 7981531
Never mind, I got it.  
0
 

Author Comment

by:ktran40
ID: 7981535
Thank you!!!
0
 
LVL 8

Expert Comment

by:Exceter
ID: 7983533
You are most welcome.
0

Featured Post

On Demand Webinar: Networking for the Cloud Era

Did you know SD-WANs can improve network connectivity? Check out this webinar to learn how an SD-WAN simplified, one-click tool can help you migrate and manage data in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

When writing generic code, using template meta-programming techniques, it is sometimes useful to know if a type is convertible to another type. A good example of when this might be is if you are writing diagnostic instrumentation for code to generat…
Article by: SunnyDark
This article's goal is to present you with an easy to use XML wrapper for C++ and also present some interesting techniques that you might use with MS C++. The reason I built this class is to ease the pain of using XML files with C++, since there is…
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will learn how to use the return statement in functions in C++. The video will also teach the user how to pass data to a function and have the function return data back for further processing.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question