I'm a beginner student learning about functions and do not understand them fully. My assignment was to write a program that deals with temperature conversion. My program had to use 6 functions (1. Program overview 2. Enter temp 3. Enter scale 4. Convert F to C 5. Convert C to F 6. Display results) It also needs to display an error message if an inappropriate input is entered for both scale (which I have) and temperature (which I do not know where to place). Appropriate values for temps are >= -459.67 F or -273.15 C. I do not know where to place this scale either. I also have multiple errors in my program. If anyone could give me any guidance in helping me to fix my program, I would greatly appreciate it!!
Code:#include <iostream> using namespace std; void programOverview (); char getScale (); int getDegree (); float convertFtoC (float); float convertCtoF (float); int getResults (); int main () { cout.precision (2); programOverview (); getDegree (); getScale(); { if (scale == "F") { convertFtoC(); } else if (scale == "C") { convertCtoF(); } else cout << "ERROR: Invalid temperature scale" << endl; } getResults(); return 0; } //This function displays a brief overview explaining the program to the user void programOverview () { cout << "This program will convert a temperature reading provided in" << endl; cout << "either Fahrenheit or Celsius to the other measurement scale." << endl; } //This function requires the user to enter the temperature scale to be used char getScale () { char scale; cout << "Enter the letter of the temperature scale that will be used:" << endl; cout << "F = Fahrenheit; C = Celsius)" << endl; cin >> scale >> endl; return scale; } //This function requires the user to enter the temperature reading in degrees int getDegree () { int degree; cout << "Enter your temperature reading in degrees:" << endl; cin >> degree; return degree; } //This function converts a Fahrenheit temperature to Celsius float convertFtoC (float Ftemp) { float Ctemp; Ctemp = (Ftemp - 32) / 1.8; return Ctemp; } //This function converts a Celsius temperature to Fahrenheit float convertCtoF (float Ctemp) { float Ftemp; Ftemp = 1.8 * Ctemp + 32; return Ftemp; } //This function displays the results { int getResults () cout << "Your temperature reading converts as follows:" << endl; cout << "Fahrenheit:" << return Ftemp << endl; cout << "Celsius:" << return Ctemp << endl; }



LinkBack URL
About LinkBacks



stream::flush() actually returns an ostream&, but it's often not used: