English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

I've been trying to code this for hours! Below is the page with the problem and I've included my code. Thank you.

P.S. This is in C++



http://www.putfile.com/pic.php?img=4828206
______________________________________

#include

using std::cout;
using std::cin;
using std::endl;
int getFahrenheit();
int calcCelsius();
int main()
{

//declare variables
int fahrenheitTemperature= 0;
int celsiusTemperature=0;
//call

fahrenheitTemperature=getFahrenheit();

//display output item
cout << "Celsius temperature:" << celsiusTemperature << endl;
system ("Pause");
return 0;
} //end of main function

int getFahrenheit()
{
int fahrenheitTemperature;
cout << "Enter fahrenheit temperature:";
cin >> fahrenheitTemperature;
return fahrenheitTemperature;
}

int calcCelsius()
{
int celsiusTemperature;
celsiusTemperature = 5.0/9.0 * fahrenheitTemperature;
return calcCelsius;
}

2007-02-21 11:56:17 · 4 answers · asked by Christi 4 in Computers & Internet Programming & Design

4 answers

I do not see your call to calcCelsius(), you should call it after the return from getFarenheit, and although this should work, (no compiler on this machine) I don't like the global scope on your vars. Consider passing them and using local vars in the future.

2007-02-21 12:09:17 · answer #1 · answered by Gene M 6 · 0 0

I know I shouldn't but...

using std::cout;
using std::cin;
using std::endl;
int getFahrenheit();
int calcCelsius(int x);
int main()
{

//declare variables
int fahrenheitTemperature= 0;
int celsiusTemperature=0;
//call

fahrenheitTemperature=getFahrenheit();
celsiusTemperature = calcCelsius(fahrenheitTemperature);

//display output item
cout << "Celsius temperature:" << celsiusTemperature << endl;
system ("Pause");
return 0;
} //end of main function

int getFahrenheit()
{
int fahrenheitTemperature;
cout << "Enter fahrenheit temperature:";
cin >> fahrenheitTemperature;
return fahrenheitTemperature;
}

int calcCelsius(int x)
{
int celsiusTemperature;
celsiusTemperature = 5.0/9.0 * x;
return calcCelsius;
}

I know its painful but this stuff gets easier the more you work with it.

2007-02-21 20:19:59 · answer #2 · answered by bytekhan 2 · 1 0

I don't see what's happening on the getFahre... i suppose that you're calling getFarenheit().

As said before you're not calling calcCelsius() so the final result is going to be 0 as celciusTemperature is assigned 0 at the beginning.

2007-02-21 20:16:21 · answer #3 · answered by f0vela 2 · 0 0

Go get a programmer, I'm clueless.

2007-02-21 20:04:04 · answer #4 · answered by LeGuy 3 · 0 3

fedest.com, questions and answers