Temperature #WSQ05

1 min read

This program includes the conditionals if and else. Basically, you establish a condition, if it’s true the program will do a series of actions you want it to do and, if it’s false, will do other series of actions determined by you. The way to write conditionals is like this:

if(condition)

{

series of actions if true

}

else

{

series of actions if false

}

 

The program below asks the temperature in Farenheit, then it converts it to Celcius and finally it prints in the screen a text that says if the water boils or not, depending on the temperature the user introduced at the beginning.

Here’s the program executed introducing two temperatures, 32 ºF (water does not boil at this temperature) and 212 ºF (water boils at this temperature).

To complet this task, I consulted pages 33 and 34 of the book “How to think like a computer scientist” by Allen B. Downey.

CC BY 4.0 Temperature #WSQ05 by Alan Valdovinos is licensed under a Creative Commons Attribution 4.0 International License.

Comments are closed.