converter * * Programmer: Dan Bennett * * Date: Oct 4, 2001 * * * * This program will prompt the user for the temprature in Fahrenheit * * and calculate the temprature in Celsius * * The formula C = 5/9(f-32) is used * ************************************************************************/ #include #include // gives us setw and setprecision int main () { float input, // the temprature in f. tempinc; // the calculated temprature // used fixed point and show the decimal point in floats // this is from A14 of the book. // because the g++ compiler is not quite up to snuff cout.setf(ios::fixed, ios::floatfield); cout.setf(ios::showpoint); // Get the temprature from the user cout << "Please enter the temprature in fahrenheit: "; cin >> input; // Note we set the precision and the width for output cout << "You entered a temprature of " << setw(6) << setprecision(2) << input <<" degrees Fahrenheit" << endl; // Calculate the temprature in c tempinc = float (5)/9*(input-32); // output the results; cout << "That is the same as " << setw(6) << tempinc << " in Celsius" << endl; return 0; }