/******************************************************************************************** 2_21r2.cpp Jim Millard for CO311
Solution rewritten to do work and input 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); int main() { float degC, degF; degC = PromptAndGet(); degF = CtoF(degC) // \370 is the ASCII code for the degree symbol cout << endl << "\t" << degC << "\370C is the same as " << degF << "\370F." << endl; 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.); }