Hi, as I posted earlier, what I need to do is get a user to input the temperature in celsius (and if input in farenheit, convert it to celsius first) and the windspeed, and have the program calculate the windchill. I have one error in line 88 of the program that says WINDCHILL can not be used as a function. I have only been C++ing for a month, so I don't understand why this is so.
If anyone can help me get my program to run, I would be very greatful.
Thanks.
#include <iostream>
#include <cmath>
using namespace std;
void FtoC(double FARENHEIT, double& TEMPERATURE); //Gets input in farenheit, makes conversion to Celsius, displays results.
void TEMPinC(double& TEMPERATURE); //Asks user for the temperature in Celsius.
void WINDSPEED(double& SPEED);
//Asks user for the wind speed in m/sec.
void WINDCHILL(double WINDSPEED, double TEMPERATURE, double& WINDCHILL_INDEX);
//Calculates the windchill from the input information.
void WINDCHILL_OUT(double WINDSPEED, double TEMPERATURE, double WINDCHILL_INDEX);
//Outputs the results of the conversion.
int main()
{
char repeat;
double WINDSPEED;
double TEMPERATURE;
double WINDCHILL_INDEX;
cout << "This program will take the wind speed\n"
<< "and the temperature and find the windchill index.\n\n";
do{
WINDCHILL_OUT (WINDSPEED,TEMPERATURE,WINDCHILL_INDEX);
cout << "Would you like to make another conversion?\nPlease enter y or n. ";
cin >> repeat;
}while(repeat=='y');
cout << "\nThank you and goodbye.\n";
system("PAUSE");
return 0;
}
void FtoC(double FARENHEIT, double& TEMPERATURE)
{
int which;
cout << "\nPlease enter 1 to convert celsius and\nenter 2 to convert farenheit. ";
cin >> which;
while(which !=1 && which !=2)
{
cout << "Please enter 1 or 2. ";
cin >> which;
}
if(which==1)
{
TEMPinC(TEMPERATURE);
}
else
{
cout << "Please enter the temperature in farenheit followed by enter\n";
cin >> FARENHEIT;
TEMPERATURE = (FARENHEIT-32)*(5/9);
}
}
void TEMPinC(double& TEMPERATURE)
{
cout << "Please enter the temperature in celsius followed by enter\n";
cin >> TEMPERATURE;
}
void WINDSPEED(double& SPEED)
{
cout << "\nPlease enter the windspeed in m/sec.\n";
cin >> SPEED;
}
void WINDCHILL(double WINDSPEED, double TEMPERATURE, double& WINDCHILL_INDEX)
{
WINDCHILL_INDEX=13.12+(0.6215*TEMPERATURE)-(11.37*(pow(WINDSPEED,0.16)))+(0.3965*TEMPERATURE)*(pow(WINDSPEED,0.016));
}
void WINDCHILL_OUT(double WINDSPEED, double TEMPERATURE, double WINDCHILL_INDEX)
{
double FARENHEIT;
double SPEED;
WINDSPEED(SPEED);
FtoC(FARENHEIT, TEMPERATURE);
TEMPinC(TEMPERATURE);
WINDCHILL(WINDSPEED, TEMPERATURE, WINDCHILL_INDEX);
cout << "\nWith a temperature of " << TEMPERATURE << " and a windspeed of\n"
<< WINDSPEED << " the windchill index is " << WINDCHILL_INDEX << " degrees celsius\n\n";
}