I'm just now learning to use functions. I know I probably put the static_cast converter in the wrong places, can anyone direct me>
//Converts a Fahrenheit temperature
//to a Celsius temperature
#include <iostream>
#include <iomanip>
using std::cout;
using std::cin;
using std::endl;
using std::setprecision;
using std::fixed;
//function prototypes
double getFahrenheit ();
int calcCelsius(double, int);
int main()
{
double fahrenheit = 0.0;
int celsius = 0;
fahrenheit = getFahrenheit ();
celsius = calcCelsius ();
cout << fixed << setprecision(0);
return 0;
} //end of main function
//*****function definitions*****
double getFahrenheit()
{
double fahrenheit = 0.0;
cout << "Enter Fahrenheit temperature: ";
cin >> static_cast<int>(fahrenheit);
return fahrenheit;
}
int calcCelsius (double fahrenheit)
{
int celsius = 0;
celsius = static_cast<double>(fahrenheit)5.0/9.0 * (fahrenheit - 32.0);
return celsius;
}
cin >> static_cast<int>(fahrenheit);
Why are you doing this? Just cin >> fahrenheit;
( >> needs lvalues )
static_cast<double>(fahrenheit)
You don't need this as fahrenheit is already a double
I'm trying to convert the degrees in double fahrenheit to degrees in int celsius, i'm just not sure where to convert
You don't need any casting, remove all the casting stuff and run your program.
yes you do. i'm getting conversion errors
Owesome!
Thank you Bazzy!
I hate using that static_cast stuff