I am beginner coder seeking for help. I found this program that interests me to solve. Please care to explain how to solve. Thanks very much!
Write a temperature converter that works in the following way:
1. Ask the user to enter a number (of degrees)
2. Ask the user to enter the units of that number (that is, ‘C’ for Celsius or ‘F’ for Fahrenheit)
3. Display the temperature in both Celsius and Fahrenheit units (after calculating the conversion). The relevant formulas are:
C * 9/5 +32 = F
(F-32) * 5/9 = C
4. Also display a description for the temperature according to the following table:
C F Description
100 212 Water boils
40 104 Hot Bath
37 98.6 Body temperature
30 86 Beach weather
21 70 Room temperature
10 50 Cool day
0 32 Freezing point
-18 0 Cold Day
-40 -40 Extremely Cold
Assume that the table is giving you temperature ranges. Starting from the top. If the temperature is 212 F or higher, then display “Water boils”. If higher than 104, but below 212 F, then display “Hot Bath”, and so on.
5. Ask the user if they want to exit the program. If not, continue the program from 1.
This is what I have so far. Now I need to figure how to do case ranges. ( If 212 F or higher, then display "Water boils", etc.
#include "stdafx.h"
#include <iostream>
using namespace std;
int main()
{
double ctemp, ftemp;
cout << "Please enter Celsius temperature: " << endl; //User inputs Celsius temp
cin >> ctemp;
ftemp = (ctemp * 1.8) + 32; // Formula for C to F
cout << "Fahrenheit temperature is: " << ftemp; // Celsius converts to Fahrenheit
cout << "Please enter Fahrenheit temperature: " << endl; //User inputs Fahrenheit temp
cin >> ftemp;
ctemp = (ftemp - 32) / 1.8; // Formula for F to C
cout << "Celsius temperature is: " << ctemp; // Fahrenheit converts to Celsius