Question 1 Report
During a harbour safety inspection, an officer records information about each moored boat on a handheld device. The new program asks for the berth code, hull length in metres, inspection date and whether a life ring is present. The officer can enter several records before choosing a command to stop. A report is then displayed for the harbour manager. The programmers are deciding which values need variables and which can be constants.
(a) State one item in this program that could be stored in a Boolean variable. [1]
(b) State one item that should be stored as a real number. [1]
(c) Explain why the berth code should be stored as a string even when it contains digits. [2]
(a) Whether a life ring is present, for example lifeRingPresent, can be stored as a Boolean variable because the answer is yes/no or true/false. [1]
(b) Hull length should be stored as a real number because a length in metres may have decimal places. [1]
(c) A berth code is an identifier, not a quantity to calculate with. It should therefore be a string, particularly because codes may contain letters, symbols, or leading zeroes that numeric storage would not preserve suitably. [2]
Everything you need to excel in your exams