Plz. Help me get my program to work

Please support our C++ advertiser: Intel Parallel Studio Home
Reply

Join Date: Sep 2004
Posts: 3
Reputation: HinJew is an unknown quantity at this point 
Solved Threads: 0
HinJew HinJew is offline Offline
Newbie Poster

Plz. Help me get my program to work

 
0
  #1
Sep 29th, 2004
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";
}
Reply With Quote Quick reply to this message  
Join Date: Apr 2004
Posts: 4,414
Reputation: Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future Dave Sinkula has a brilliant future 
Solved Threads: 248
Team Colleague
Dave Sinkula's Avatar
Dave Sinkula Dave Sinkula is offline Offline
long time no c

Re: Plz. Help me get my program to work

 
0
  #2
Sep 29th, 2004
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";
}
"One of the methods used by statists to destroy capitalism consists in establishing controls that tie a given industry hand and foot, making it unable to solve its problems, then declaring that freedom has failed and stronger controls are necessary." --Ayn Rand
Reply With Quote Quick reply to this message  
Join Date: Sep 2004
Posts: 40
Reputation: coolmel55 is an unknown quantity at this point 
Solved Threads: 1
coolmel55 coolmel55 is offline Offline
Light Poster

Re: Plz. Help me get my program to work

 
0
  #3
Sep 30th, 2004
I think your problem is that you have a fuction called WINDSPEED and you also have a variable: double WINDSPEED. Yup this code works!
  1. #include <iostream>
  2. #include <cmath>
  3.  
  4. using namespace std;
  5.  
  6. void ftoc(double farenheit, double& temperature); //Gets input in farenheit, makes conversion to Celsius, displays results.
  7.  
  8. void tempinc(double& temperature); //Asks user for the temperature in Celsius.
  9.  
  10. void windspeed(double& speed);
  11. //Asks user for the wind speed in m/sec.
  12.  
  13. void windchill(double wind_speed, double temperature, double& windchill_index);
  14. //Calculates the windchill from the input information.
  15. void windchill_out(double wind_speed, double temperature, double windchill_index);
  16. //Outputs the results of the conversion.
  17.  
  18. int main()
  19. {
  20. char repeat;
  21. double wind_speed = 0;
  22. double temperature = 0;
  23. double windchill_index = 0;
  24.  
  25. cout << "This program will take the wind speed\n"
  26. << "and the temperature and find the windchill index.\n\n";
  27.  
  28. do{
  29. windchill_out (wind_speed,temperature,windchill_index);
  30. cout << "Would you like to make another conversion?\nPlease enter y or n. ";
  31. cin >> repeat;
  32. }while(repeat=='y');
  33.  
  34. cout << "\nThank you and goodbye.\n";
  35.  
  36. system("PAUSE");
  37. return 0;
  38. }
  39.  
  40. void ftoc(double farenheit, double& temperature)
  41. {
  42. int which;
  43.  
  44. cout << "\nPlease enter 1 to convert celsius and\nenter 2 to convert farenheit. ";
  45. cin >> which;
  46. while(which !=1 && which !=2)
  47. {
  48. cout << "Please enter 1 or 2. ";
  49. cin >> which;
  50. }
  51. if(which==1)
  52. {
  53. tempinc(temperature);
  54. }
  55. else
  56. {
  57. cout << "Please enter the temperature in farenheit followed by enter\n";
  58. cin >> farenheit;
  59. temperature = (farenheit-32)*(5/9);
  60.  
  61. }
  62. }
  63.  
  64. void tempinc(double& temperature)
  65. {
  66.  
  67. cout << "Please enter the temperature in celsius followed by enter\n";
  68. cin >> temperature;
  69. }
  70.  
  71. void windspeed(double& speed)
  72. {
  73. cout << "\nPlease enter the windspeed in m/sec.\n";
  74. cin >> speed;
  75. }
  76.  
  77. void windchill(double wind_speed, double temperature, double& windchill_index)
  78. {
  79. windchill_index=13.12+(0.6215*temperature)-(11.37*(pow(wind_speed,0.16)))+(0.3965*temperature)*(pow(wind_speed,0.016));
  80. }
  81.  
  82.  
  83. void windchill_out(double wind_speed, double temperature, double windchill_index)
  84. {
  85. double farenheit = 0;
  86. double speed = 0;
  87.  
  88. windspeed(speed);
  89. ftoc(farenheit, temperature);
  90. tempinc(temperature);
  91. windchill(wind_speed, temperature, windchill_index);
  92.  
  93. cout << "\nWith a temperature of " << temperature << " and a windspeed of\n"
  94. << wind_speed << " the windchill index is " << windchill_index << " degrees celsius\n\n";
  95. }
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC