Question: Create a new file named convert.cpp . In this file, write a program that asks the user for a temperature, then converts that temperature to

Create a new file named convert.cpp. In this file, write a program that asks the user for a temperature, then converts that temperature to four (semi-)common temperature units.
The prompt should be Enter a temperature: (followed by a newline), and the user will enter a number, followed by a space, followed by a capital letter. The letter specifies a unit. Supported units are as follows, and the results should always print in this order, with exactly two digits after the decimal point:
C for Celsius
F for Fahrenheit
K for Kelvin
R for Rankine
[alice@wonderland lab2]$ ./convert
Enter a temperature:
98.6 F
=37.00 C
=98.60 F
=310.15 K
=558.27 R
To ensure the correct number of decimal digits, include the iomanip header and add the following line before printing your results (C++ has annoyingly quirky output formatting commands):
std::cout << std::fixed << std::setprecision(2);

Step by Step Solution

3.39 Rating (158 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Heres the code for the convertcpp file include iostream include iomanip int main Prompt the user for ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!