943,969 Members | Top Members by Rank

Ad:
  • C++ Discussion Thread
  • Unsolved
  • Views: 2387
  • C++ RSS
Sep 28th, 2004
0

New 2 C++, help with finding erros

Expand Post »
I have to write a program that takes temperature in celsius (if in farenheit, it converts it to celsius) along with the windspeed and calculates the windchill. I have the program written but I can't figure out what I'm doing wrong in lines 63 and 75. Any help would be appreciated!

#include <iostream>
using namespace std;

void FtoC(); //Gets input in farenheit, makes conversion to Celsius, displays results.

void TEMPinC (); //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();
//Outputs the results of the conversion.

int main()
{
char repeat;

cout << "This program will take the wind speed\n"
<< "and the temperature and find the windchill index.\n\n"
<< "wind speed is in m/sec, while\n"
<< "temperature is in degrees Celsius or Farenheit.\n\n";

do{
WINDCHILL_OUT();
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)
{
cout << "Please enter the temperature in farenheit followed by enter\n";
cin >> FARENHEIT;
TEMPERATURE = (FARENHEIT-32)*(5/9);
}

else
TEMPinC();
}

void TEMPinC()
{
cout << "Please enter the temperature in farenheit 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)
{
cout << "\nWith a temperature of " << TEMPERATURE << " and a windspeed of\n"
<< WINDSPEED << " the windchill index is " << WINDCHILL_INDEX << " degrees celsius\n\n";
}
Similar Threads
Reputation Points: 11
Solved Threads: 0
Newbie Poster
HinJew is offline Offline
3 posts
since Sep 2004
Sep 28th, 2004
0

Re: New 2 C++, help with finding erros

[Whoa. I'd suggest ending your preference of CAPITALIZING SYMBOLS.]

Read the error messages.
C++ Syntax (Toggle Plain Text)
  1. void TEMPinC()
  2. {
  3. cout << "Please enter the temperature in farenheit followed by enter\n";
  4. cin >> TEMPERATURE;
  5. }
I'd guess the message is something like this.
Quote ...
'TEMPERATURE' : undeclared identifier
I find that self-explanitory. There is no variable TEMPERATURE in the function TEMPinC.

The other one is the same issue, but different. You are using the pow function without including its header <cmath>.
Team Colleague
Reputation Points: 2780
Solved Threads: 312
long time no c
Dave Sinkula is offline Offline
4,790 posts
since Apr 2004
Sep 28th, 2004
0

Re: New 2 C++, help with finding erros

One of many erros in your program that show up is that you did not enter TEMPERATURE in main or in the function,so the function does not know the varable name to access it. :cry:
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Chester1 is offline Offline
11 posts
since Sep 2004
Sep 28th, 2004
0

Re: New 2 C++, help with finding erros

You Also donot have a function or code for pow(),also it must be declair before main also.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
Chester1 is offline Offline
11 posts
since Sep 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in C++ Forum Timeline: Halp in breaking a loop
Next Thread in C++ Forum Timeline: Help for a Specialised project





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC