Temperature Converter

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.
Make a start, that list gives you every step you need to try.

Once you get stuck post the code here and ask a specific question.
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



return 0;
}
closed account (48T7M4Gy)
If 212 F or higher, then display "Water boils"


1
2
if( ftemp blah blah )
  cout << "More stuff << end; 


Hint: <= 212 would mean 212 or lower. You need && or || for multiple conditions
Last edited on
So what would you say for

"If higher than 104 F, but below 212F , then
display “Hot Bath” ??
closed account (48T7M4Gy)
What would you say?

What have you said for the first one?
Last edited on
1
2
if (ftemp >= 212)
		cout << "Water boils: " << endl;
closed account (48T7M4Gy)
Great stuff.

The next one has 2 conditions

1
2
if ( ftemp blah bla && ftemp >=  stuff)
 cout whatever;
Topic archived. No new replies allowed.