Skip to content

Course home

Structured programming and subroutines (procedures and functions)

Structured programming and subroutines (procedures and functions)

EasyMediumHard
12345678910111213141516
Question 16

Write a C# program to control a deep-sea salvage submarine.

The program should:

  • get the user to enter the depth of a crate to salvage
  • get the user to enter the distance of a crate to salvage
  • check if the crate at the position entered is within reach of the submarine's claw
    • if it is, retrieve the cargo at that position
    • if it is not, output Target depth or distance unreachable
  • repeat these steps until all salvage operations are complete.

You must use the subroutines described in the tables below.

Subroutine Table 1

SubroutinePurpose
isSalvageComplete()Returns true if all cargo crates have been salvaged. Otherwise, returns false.
isCrateReachable(depth, distance)Returns true if the crate at (depth, distance) is within range of the submarine's claw. Otherwise, returns false.

Subroutine Table 2

SubroutinePurpose
retrieveCargo(depth, distance)Activates the claw to salvage the crate at (depth, distance), if that crate is reachable.

You should use meaningful variable name(s) and C# syntax in your answer.

[6]
Markscheme

Structured programming and subroutines (procedures and functions) Questions

  1. GCSE
  2. /Computer Science
  3. /Structured programming and subroutines (procedures and functions)

131 exam-style questions on AQA GCSE Computer Science Structured programming and subroutines (procedures and functions). Each one has a worked solution and a mark scheme showing where the marks go.

Question bank