Distance of mountain pass in miles 145.87
Question 1.1
Write code to convert the distance entered into kilometres - NSC Information Technology - Question 1 - 2016 - Paper 1
Question 1
Distance of mountain pass in miles 145.87
Question 1.1
Write code to convert the distance entered into kilometres. Display the converted value and unit (km) in the... show full transcript
Worked Solution & Example Answer:Distance of mountain pass in miles 145.87
Question 1.1
Write code to convert the distance entered into kilometres - NSC Information Technology - Question 1 - 2016 - Paper 1
Step 1
Extract the distance from the text box as an integer
96%
114 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Use the input from the text box to get the distance in miles, converting it from a string to an integer format.
Step 2
Calculate the distance in kilometers
99%
104 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Use the formula:
Distance=Miles×1.6
This conversion factor will turn miles into kilometers.
Step 3
Display the distance in the output window
96%
101 rated
Only available for registered users.
Sign up now to view full answer, or log in if you already have an account!
Answer
Output the calculated distance value along with the label 'km' for clarity, ensuring it’s formatted correctly in the output display.