Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

Heres the code for the convertcpp file include iostream include iomanip int main Prompt the user for ... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Matlab An Introduction with Applications

Authors: Amos Gilat

5th edition

1118629868, 978-1118801802, 1118801806, 978-1118629864

More Books

Students also viewed these Programming questions

Question

Mention the types of maps

Answered: 1 week ago