Question 1 Report
A coastal rescue service is to replace its paper incident cards with a program that creates a radio message for each call. A controller enters a caller's name, a beach code and a short incident description. The skeleton program must remove accidental spaces at either end of each entry, convert the beach code to upper case and build one displayed message. For example, the entries " Mina Patel ", "sw-17" and "inflatable boat drifting" should create a clear message without changing the case of the description.
(a) Explain why trimming the name before it is stored improves the quality of the data. [2]
(b) When the beach code is sw-17, state the value after it has been converted to upper case. [1]
(c) Explain how concatenation can be used to create the message CALLER: Mina Patel | LOCATION: SW-17. [3]
(d) When a description has 68 characters, explain how the program can test whether it exceeds the 60-character radio limit. [2]
(e) Explain how a substring operation could extract 17 from the code SW-17. [2]
(f) When the first character of a caller name is a space, explain how the program should respond before sending the message. [2]
(g) Explain the difference between using a character position and using the length of a string in this program. [2]
(h) When a controller enters an empty description, explain one suitable validation message and why it is needed. [2]
(i) Explain one reason why the program should keep the original incident description as well as the shortened radio message. [2]
(a) Trimming removes leading and trailing spaces from the name. [1] This avoids names that only appear different because of accidental spaces and improves matching and display quality. [1]
(b) Converting sw-17 to upper case gives SW-17. [1]
(c) Concatenation joins strings together. Combine the literal label CALLER: , the cleaned name Mina Patel, the separator | LOCATION: , and the cleaned code SW-17. [1][1] The resulting single string is CALLER: Mina Patel | LOCATION: SW-17. [1]
(d) Use a length function on the description. [1] Compare its result with 60; since \(68>60\), the program should reject it or display a warning. [1]
(e) Select the characters after the hyphen, which are positions 4 and 5 in SW-17. [1] The substring produced is 17. [1]
(f) Trim the entry to remove the leading space. [1] Then validate it or reject it if no name remains after trimming. [1]
(g) A character position identifies where a particular character occurs in a string. [1] String length is the total number of characters in that string. [1]
(h) A suitable message is Enter an incident description. [1] It prevents a blank, unusable emergency record from being sent or stored. [1]
(i) The original description retains all the incident detail. [1] A shortened radio message may omit information needed later. [1]
Everything you need to excel in your exams