This lesson can be used by Mathematics teachers keen to include programming and logical thinking as part of their course. However, it is suggested that students complete The Basics page to familiarise themselves with relevant skills on which this lesson builds.
Did you know that NASA once lost a $125 million spacecraft because two teams were using different units of measurement?
Where do you look when you want to convert:
You may do an Internet search or use a relevant app. Do you think the code used in the program would be complicated? What might it include?
In this lesson, students will:
Introduce the task to create a computer program that converts a temperature value in Celsius to a temperature value in Fahrenheit.
As a class, or in teams, design the program as a flowchart. Students must research and fill in the Maths operation. (Temp in Celsius) × 9 ÷ 5 + 32.
Image: Flow chart for temperature converter
#This program converts degrees Celsius (°C) into degrees Fahrenheit (°F) BEGIN Display “Enter the temperature in degrees Celsius:” celsius ← input from user fahrenheit ← celsius × 9 ÷ 5 + 32 Display “The temperature is “, fahrenheit, “ degrees Fahrenheit.” END
For more on setting up and choosing a language, see Setting up.
To review concatenation, variables and user input and output, head back The Basics page.
It’s time to code our temperature converter. This will require storing what the user types in (user input). View the ‘Celsius converter’ video to learn how to create a program to convert temperature. This video covers the entire process of building the code. Solution code is provided for checking.
To make the program more user-friendly, use concatenation – joining text together – for a better output display. View the ‘Celsius converter (concatenation)’ video. This video covers the process of using concatenation to improve output. Solution code is provided for checking.
These challenges use the skills covered so far. By writing or modifying their own programs, students have an opportunity to demonstrate Application and Creation.
Challenge early finishers to try more complex conversions, like capacity (square centimetres to litres) or battery capacity (amp hours to kilowatt hours for a given voltage).
(OPTIONAL) Have a go at converting currency (eg USD to AUD).
View the ‘Currency converter’ video. This video covers the process of creating a program to convert between USD to AUD. Solution code is provided for checking.
For this conversion, the Google currency converter has an advantage over your own program. Why?