Eco-Freight logistics calculates the carbon footprint of transport journeys.
The carbon footprint (g g\,g of CO2CO_2CO2) is calculated using the following expression:
footprint=distance×weight×emissions factor \text{footprint} = \text{distance} \times \text{weight} \times \text{emissions factor} footprint=distance×weight×emissions factorHere is a partially completed pseudo-code representation of an algorithm designed to calculate this footprint.
2 FUNCTION calcFootprint ( )
3
4 BEGIN FUNCTION
5
6 footprint =
7
8 RETURN
9
10 END FUNCTION
11
12 SEND "Enter distance in km" TO DISPLAY
13 RECEIVE tripDistance FROM (REAL) KEYBOARD
14 SEND "Enter cargo weight in tonnes" TO DISPLAY
15 RECEIVE cargoWeight FROM (REAL) KEYBOARD
16 SEND "Enter vehicle emissions factor" TO DISPLAY
17 RECEIVE vehicleFactor FROM (REAL) KEYBOARD
18
19 SET totalFootprint TO
20
21 SEND "Total footprint is " & totalFootprint TO DISPLAY
The function calcFootprint must represent a generalisation that can calculate the footprint for any cargo run using local parameters.
Complete the pseudo-code by writing the code required for lines 2, 6, 8, and 19.
Practise Edexcel GCSE Computer Science Subprograms with exam-style questions for GCSE Computer Science. 29 questions covering Built-in and user-devised subprograms, Functions versus procedures, and Global and local variables, matched to the Edexcel GCSE Computer Science (1CP2) specification and written in Paper 1 and Paper 2 style. Every question includes a full worked solution and mark scheme, so you can see where marks are awarded rather than just whether you got the answer right.