/******************************************************************************************** 2_21r3.cpp Jim Millard for CO311
Solution rewritten to do input, work and output in separate functions Simple program that takes a temperature in celsius and converts it to fahrenheit for display. ********************************************************************************************/ #include <iostream> #include <string> using namespace std; float PromptAndGet(); float CtoF(const float C); void DisplayResults(const float C, const float F); int main() { float degC, degF; degC = PromptAndGet(); degF = CtoF(degC) DisplayResults(degC, degF); return 0; }
float PromptAndGet() { float temp; cout << endl << " Enter the Celsius temperature you wish to convert: " ; cin >> temp; return temp; } float CtoF(const float C) { return ((9./5.) * C + 32.); } void DisplayResults(const float C, const float F) { // \370 is the ASCII code for the degree symbol cout << endl << "\t" << C << "\370C is the same as " << F << "\370F." << endl; return; }