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";
}

Edited 3 Years Ago by Dani: Formatting fixed

You tell the compiler that WINDSPEED is a double.

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";
}

I think your problem is that you have a fuction called WINDSPEED and you also have a variable: double WINDSPEED. Yup this code works!

#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 wind_speed, double temperature, double& windchill_index);
          //Calculates the windchill from the input information.
void windchill_out(double wind_speed, double temperature, double windchill_index);
          //Outputs the results of the conversion.

int main()
{
char repeat;
double wind_speed = 0;
double temperature = 0;
double windchill_index = 0;

      cout << "This program will take the wind speed\n"
           << "and the temperature and find the windchill index.\n\n";

      do{
      windchill_out (wind_speed,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 wind_speed, double temperature, double& windchill_index)
{
windchill_index=13.12+(0.6215*temperature)-(11.37*(pow(wind_speed,0.16)))+(0.3965*temperature)*(pow(wind_speed,0.016));
}


void windchill_out(double wind_speed, double temperature, double windchill_index)
{
double farenheit = 0;
double speed = 0; 

windspeed(speed);
ftoc(farenheit, temperature);
tempinc(temperature);
windchill(wind_speed, temperature, windchill_index);

  cout << "\nWith a temperature of " << temperature << " and a windspeed of\n"
       << wind_speed << " the windchill index is " << windchill_index << " degrees celsius\n\n";
}
This article has been dead for over six months. Start a new discussion instead.