Convert - << endl cin>> tempIn if(letter =='F...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
// file: Convert.cpp // author: j. dzuback // modified: // date: today / /* ********************************************************** Program Convert converts a temperature from Fahrenheit to Celsius or a temperature from Celsius to Fahrenheit depending on whether the user enters an F or a C. ********************************************************** */ #include <iostream> using namespace std; u int ConvertedTemp(int tempIn, char letter); // If letter is a 'C,' tempIn is converted from Celsius // to Fahrenheit; otherwise tempIn is converted from // Fahrenheit to Celsius. / int main () { char letter; // Place to store input letter int tempIn; // Temperature to be converted cout << "Input Menu" << endl << endl; cout << "F: Convert from Fahrenheit to Celsius" << endl; cout << "C: Convert from Celsius to Fahrenheit" << endl; cout << "Q: Quit" << endl; cout << "Type a C, F, or Q; then press return." << endl; cin >> letter; while (letter != 'Q') { cout << " Type an integer number, and press return."
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full Document Right Arrow Icon
Background image of page 2
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: << endl; cin >> tempIn; if (letter == 'F') cout << "Fahrenheit to Celsius" << endl; else cout << "Celsius to Fahrenheit" << endl; cout << "Temperature to convert: " << tempIn << endl; cout << "Converted temperature: " << ConvertedTemp(tempIn, letter) << endl << endl; cout << "Type a C, F, or Q; then press return." << endl; cin >> letter; } return 0; } /* ***************************************************** Function converts temperature from celsius to fahenheit or from fahrenheit to celsius based on code supplied Pre conditions: an interger temperature a letter code, 'C' or 'F'. Post condition: interger temperature will be converted from one scale to the other, based on code. ***************************************************** */ int ConvertedTemp(int tempIn, char letter) { if (letter == 'C') return (9 * tempIn / 5) + 32; else return 0; }...
View Full Document

{[ snackBarMessage ]}

Page1 / 2

Convert - << endl cin>> tempIn if(letter =='F...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online