Question 1 Report
For each photograph uploaded to a wildlife survey website, the program creates a safe file name. The function makeFileName(siteCode, photoNumber) returns text in the form siteCode_photoNumber.jpg. For example, site code RIV and photograph number 27 should produce RIV_27.jpg. A separate procedure later saves the image using this returned text. The survey team needs the same naming rule in a desktop program used at remote field stations.
(a) Explain why makeFileName should return a string rather than display the file name. [2]
(b) When called with makeFileName("RIV", 27), state the returned string. [1]
(c) Explain one advantage of using this function in both versions of the survey program. [1]
(a) makeFileName should return a string because the file name must be passed to the saving procedure or stored for later use. Displaying it would only show output and would not provide a usable value to other program statements. [2]
(b) The returned string is RIV_27.jpg. [1]
(c) Using the same function makes the file-naming rule consistent in both programs. A later change to the rule can be made once in the function rather than separately in each use. [1]
Everything you need to excel in your exams