Can someone help me with my code, I keep having issues in several lines.
This is what I wanted to accomplish.
MAIN FUNCTION () : This function will call the functions below.
Function #1: displays menu
Function #2: converts celsius to fahrenheit
Function #3: converts fahrenheit to celsius
Function #4: displays result
Function #5 if desired handles error checking
#include <iostream>
usingnamespace std;
void programOverview ();
char getScale ();
float getDegree ();
float convertFtoC (float);
float convertCtoF (float);
void getResults ();
int main ()
{
cout.precision (2);
programOverview ();
float degree = getDegree ();
char scale = getScale();
if (scale == 'F')
{
convertFtoC(degree);
}
elseif (scale == 'C')
{
convertCtoF(degree);
}
else
cout << "I'm Sorry. That isn't a valid input" << endl;
getResults();
return 0;
}
//Explains what the program will do
void programOverview ()
{
cout << "Hello! Welcome to F to C Converter" << endl;
cout<< " This program will convert a temperature in"<< endl;
cout << "either Fahrenheit or Celsius." << endl;
}
//This function requires the user to either enter Celsius or Fahrenheit to be converted
char getScale ()
{
char scale;
cout << "Please type either C for Celsius or F for Fahrenheit:" << endl;
cout << "F = Fahrenheit; C = Celsius)" << endl;
cin >> scale;
return scale;
}
//This function requires the user to enter the temperature in degrees
float getDegree ()
{
float degree;
cout << "Enter the temperature you wish to convert in degrees:" << endl;
cin >> degree;
return degree;
}
//This function converts Celsius to Fahrenheit
float convertCtoF (float Ctemp)
{
float Ftemp;
Ftemp = 1.8 * Ctemp + 32;
return Ftemp;
}
//This function converts Fahrenheit to Celsius
float convertFtoC (float Ftemp)
{
float Ctemp;
Ctemp = (Ftemp - 32) / 1.8;
return Ctemp;
}
//This function displays the results
void getResults (Ctemp, Ftemp)
{
cout << "Your temperature reading converts as follows:" << endl;
cout << "Fahrenheit:" << Ftemp << endl;
cout << "Celsius:" << Ctemp << endl;
}
Right off the bat, it appears you didn't correctly define the programOverview() function. Look at line 34-39. It doesn't look like you put the function's header in.