CAMBRIDGE IGCSE COMPUTER SCIENCE
Summer 2025 · Paper 22 · Question 10 · 15 marks
← 0478 CS Hub Paper 22 · Summer 2025 0478 / Paper 2 Question 10 15 MARKS
15-mark question lab · start here

Volumes returned by three functions, driven by a validated menu.

Build the solution in a sensible order: understand the three formulae, declare every variable and the constant Pi, write one function per shape with the input data as parameters, then drive them from a validated menu that loops until the user chooses stop and outputs each volume rounded to two decimal places. Learn the reasoning before revealing the complete program.

Functions with parametersValidated menu loopCASE selectionConstant Pi = 3.142Rounding to 2 dp15 marks

Learning targets

By the end, you should be able to explain the algorithm before writing it.

Lesson overview

01 · Understand

Identify the three formulae, the shared menu loop, and why each function must receive its input data as parameters.

02 · Construct

Write one function per shape, each returning its volume, and select between them with a validated menu choice.

03 · Complete

Declare every variable and the constant Pi = 3.142, round each output to two decimal places, and stop only on the stop option.

!

How Cambridge awards the marks: the mark scheme gives AO2 a maximum of 9 marks and AO3 a maximum of 6 marks. It lists requirements R1–R5, but does not assign a separate fixed mark total to each R requirement. The stage-to-mark links in this guide show alignment, not invented stage marks.

Source question

Read the whole question first

Do not begin coding after the first paragraph. The exact formulae, the validated menu, the function-per-shape rule and the two-decimal rounding all shape the structure of your solution.

Question 10 · 15 marks
Cambridge IGCSE Computer Science · 0478/22 · Question 10

A program is required to allow students to calculate the volume of a number of standard three-dimensional shapes. It will use functions to allow other shapes to be added in the future.

Cuboid

volume = base × depth × height

Triangular prism

volume = ½ × base × depth × height

Sphere

volume = 4/3 × Pi × radius × radius × radius

Pi is a constant with value 3.142

Write a program that meets the following requirements:

  • Output a menu to ask the user for an input to indicate the shape for which a volume needs to be calculated, from the three shapes given or if they want to stop the program. The program must validate the input.
  • Input the data needed to calculate the volume of the chosen shape, based on the given formulae.
  • Create one function for each shape to calculate and return the volume using the given formulae. Each function uses the input data as parameters.
  • Output the volume in the main program, rounded to two decimal places.

The program continues until the user inputs the stop option from the menu.

You must use pseudocode or program code and add comments to explain how your code works.

All variables and constants used must be declared for this algorithm.

All inputs and outputs must contain suitable messages.

Before you move on

These are the five required techniques identified by the Cambridge mark scheme.

Mark-scheme map
R1

Output a validated menu offering the three shapes or the stop option, and keep looping until the stop option is chosen.

R2

Input the data the chosen shape's formula needs — base, depth and height for the cuboid and prism, radius for the sphere.

R3

Create one function per shape — Cuboid, TriangularPrism and Sphere — taking the input data as parameters and returning the volume.

R4

Output each volume in the main program, rounded to two decimal places.

R5

Declare every variable and the constant Pi = 3.142, comment the code, and give every input and output a suitable message.

Use the tabs along the top to work through the seven stages. The complete solution is kept in its own tab, and the interactive visualisation is the final tab.