#WSQ05 – Temperature

Now, we’re going to learn how to use conditionals. This task requests the following steps:

  • Write a program that will prompt the user for a temperature in Fahrenheit and then convert it to Celsius. You may recall that the formula is C = 5 ∗ (F − 32)/9.
  • Modify the program to state whether or not water would boil at the temperature given.

So, let’s do it:

TempWSQ05

Ask for the temperature (“F”).

CWSQ05

Our second variable (“C”) is the formula to convert from Fahrenheit degrees to Celsius degrees, so just include your variable in the formula and you’re good.

#Tip: Use “//” on divison for evading float numbers like 35.77777777777.

PWSQ05

Do the first simple print, showing the two variables you got.

IWSQ05

Time of conditionals (“if” in this case); the first one actually applies for every celsius temperature that is under 100 celsius degrees, if this condition applies, a sentence saying that water will not boil at the temperature we typed will be printed. So, in the second one, for every temperature that passes 100 celsius degrees, a sentence saying that water will boil at the temperature we typed will be printed.

And that’s it, we just have to run the program:

RunWSQ05

There’s the full program:

FullWSQ05

We’re doing good, let’s keep moving.

CC BY-SA 4.0 #WSQ05 – Temperature by manuelmendezhijar is licensed under a Creative Commons Attribution-ShareAlike 4.0 International License.