Skip to content

Course home

Sign up

Subprograms

EasyMediumHard
12345678910111213141516
Question 6

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 factor

Here 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.

[4]
Markscheme

Subprograms Questions

  1. GCSE
  2. /Computer Science
  3. /Subprograms

29 exam-style questions on Edexcel GCSE Computer Science Subprograms, covering Built-in and user-devised subprograms, Functions versus procedures, and Global and local variables. Each one has a worked solution and a mark scheme showing where the marks go.

Question bank