ExamBank Scot · Higher Computing Science question bank · All Higher Computing Science questions
10 marks · Design notations and data flow
Complete the table below to show the missing data flow for Steps 2, 3 and 4 of this program. Step IN OUT 1 name(), region(), month(), year() 2 3 numStormsYear() 4 Using a design technique of your choice, design an algorithm for Step 2. The program is to be extended to allow a user to enter a possible name for a future storm. Storm names should be unique. The program should check if the name entered is already present in the array name. A suitable message should be displayed to tell the user if the name is present or not. Using a programming language of your choice, write the code for this new feature. Storms that affect Scotland are named. The name, region affected, month and year of each storm from each of the five years 2020–2024 is stored in a csv file. Sample data from this file is shown below. … Robyn, North East, November, 2020 Brendan, North West, January, 2021 Ciara, South, February, 2021 Dennis, South East, September, 2021 … A program is used to: 1. read data from file into parallel 1D arrays 2. ask for a year then count and display the number of autumn storms in that year 3. count the number of storms for each year 4. display the year with the most storms. Autumn months are September, October and November.
Step 2: IN: month(), year() OUT: Step 3: IN: year() OUT: Step 4: IN: numStormsYear() OUT: Award 1 mark for each step. For each step the mark is awarded for the correct IN with no additional parameters (with exception of year() in Step 4). Brackets must be indicated. • initialise and increment of count • input from user, loop and output • condition for targetYear • condition for autumn (September, October, November) with OR including brackets Candidates may use nested if for fourth bullet which would not require brackets. • declaration and use of flag to determine presence • loop for correct range and both output messages • input of name and if condition for given name “Name not used” output must be outside of loop. Example answer: DECLARE stormName INITIALLY FROM KEYBOARD DECLARE found INITIALLY False FOR index = 0 to length(name) - 1 IF name[index] = stormName THEN SET found TO True SEND “Name already used” TO DISPLAY END IF END FOR IF found = False THEN SEND “Name not used” TO DISPLAY END IF