Rebekah_S
Oct 23, 2007, 05:52 PM
I am very new to the world of C++, but was asked to program a Fahrenheit to Celsius converter application. I FINALLY got the code to not give me any error messages, but every time I execute the application, the output answer for celsius is 0. Could anyone help me determine where the problem is??
#include <iostream>
#include <iomanip>
using std::cout;
using std::cin;
using std::endl;
using std::setprecision;
using std::ios;
using std::setiosflags;
//function prototypes
int getFahrenheit();
int calcCelsius(int, int);
int main()
{
int far = 0;
int subt = 32;
int cel = 0;
far = getFahrenheit();
//display celTemp
cout << setiosflags(ios::fixed) << setprecision(0);
cout << "Celsius temperature is: " << cel << endl;
return 0;
} //end of main function
//*****function definitions*****
int getFahrenheit()
{
double FahrenH = 0.0;
cout << "Enter temperature in Fahrenheit: ";
cin >> FahrenH;
return FahrenH;
} //end of getFahrenheit function
int calcCelsius(int far, int subt)
{
int cel = 0.0;
cel = (5.0*(far - subt)/9.0);
return cel;
} //end of calCelsius function
#include <iostream>
#include <iomanip>
using std::cout;
using std::cin;
using std::endl;
using std::setprecision;
using std::ios;
using std::setiosflags;
//function prototypes
int getFahrenheit();
int calcCelsius(int, int);
int main()
{
int far = 0;
int subt = 32;
int cel = 0;
far = getFahrenheit();
//display celTemp
cout << setiosflags(ios::fixed) << setprecision(0);
cout << "Celsius temperature is: " << cel << endl;
return 0;
} //end of main function
//*****function definitions*****
int getFahrenheit()
{
double FahrenH = 0.0;
cout << "Enter temperature in Fahrenheit: ";
cin >> FahrenH;
return FahrenH;
} //end of getFahrenheit function
int calcCelsius(int far, int subt)
{
int cel = 0.0;
cel = (5.0*(far - subt)/9.0);
return cel;
} //end of calCelsius function