Question
C++ // Program Convert converts a temperature from Fahrenheit to // Celsius or a temperature from Celsius to Fahrenheit // depending on whether the user
C++
// 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
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
cin >> letter; while (letter != 'Q') { cout > tempIn;
if (letter == 'F') cout
cin >> letter; } return 0; }
// *****************************************************
int ConvertedTemp(int tempIn, char letter) { if (letter == 'C') return (9 * tempIn / 5) + 32; else return 5 * (tempIn - 32) / 9; }
Exercise 4: Program Convert is an old friend. This version uses an int function to convert temperatures from Fahrenheit to Celsius or from Celsius to Fahrenheit. Examine program Convert carefully. The next exercises ask you to modify itStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started