Your answers to this tutorial will be used in the next tutorial.
For the following questions, work through steps 1 (Understanding) through 5 (Desk Checking) of the Steps in Program Development discussed in the lecture.
A shop owner requires a program to calculate the GST payable on items purchased. The GST is one-tenth of the pre GST price. For example, if the pre-GST price was $100 then the GST is $10 and the price including GST is $110. The user is to input the pre-GST price and the program is to display the GST and the final price including GST.
Run Pre GST Price ($) ? 100 GST = $10.00 Price Including GST = $110.00
Run Pre GST Price ($) ? 5.50 GST = $0.55 Price Including GST = $6.05
An athlete is interested in their average speed over a distance. The user is to input the distance (in km) and time taken (in seconds) and the average speed in kilometres per hour is to be displayed. Firstly, as the speed is in kilometres per hour, the time taken in seconds needs to be converted to hours; there are 3600 seconds in an hour, so dividing the time in seconds by 3600 gives the time taken in hours, so 1800 seconds = 1800 ÷ 3600 = 0.5 hours. For example if the athlete travelled 5km in 1800 seconds, then their average speed is calculated as follows: 1800 seconds is 1800 ÷ 3600 hours = 0.5 hours. The average speed is the distance travelled (in km) divided by the time taken (in hours) = 5 km ÷ 0.5 hours = 10kph.
Run Distance (km) ? 15 Time taken (sec) ? 3600 Average speed = 15kph Run Distance (km) ? 5 Time taken (sec) ? 1800 Average speed = 10kph