Just having a little trouble. I get an error when it compiles. Here's my code:
// Begin program
#include <iostream>
using namespace std;
double tempvert(double, char); //<----Probably here is why I can't get it to run
// because I'm using a double and char in the the same prototype?
int main ()
{
double tempVal, final;
char tempLetter;
cout << "Enter a temperature: ";
cin >> tempVal;
cout << "Enter a letter (f for fahrenheit): ";
cin >> tempLetter;
final = tempvert(tempVal, tempLetter);
cout << "The temperature conversion is " << final << endl;
return 0;
}
double tempvert(double x, char y) //<----Here as well.
{
double result;
if (y == 'f')
result = (5.0/9.0) * (x - 32.0);
else
result = (9.0/5.0) * x + 32.0;
return result;
}
// End Program
Any help would be appreciated. Thanks!
Last edited on