| | |
Plz. Help me get my program to work
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
•
•
Join Date: Sep 2004
Posts: 3
Reputation:
Solved Threads: 0
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";
}
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";
}
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
•
•
Join Date: Sep 2004
Posts: 40
Reputation:
Solved Threads: 1
•
•
•
•
I think your problem is that you have a fuction called WINDSPEED and you also have a variable: double WINDSPEED. Yup this code works!
C++ Syntax (Toggle Plain Text)
#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"; }
![]() |
Similar Threads
- can someone PLZ help me with this program! (C++)
- Reload this Page problems making python program work with py2exe (Python)
- Make program work on other PCs (VB.NET)
- How do i make my program work for 5 times and then Expire (VB.NET)
- the program don't seem to work (VB.NET)
- need help to make this program work (C++)
- hOW DOES THIS PROGRAM WORK? processor (C)
Other Threads in the C++ Forum
- Previous Thread: How to read in a sentence and insert in to linked list?
- Next Thread: Converting Hexadecimal characters to integers.
| Thread Tools | Search this Thread |
api application array arrays based beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator getline graph homeworkhelper iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg simple sorting string strings template text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets






