Implementation (Data Types) (SQA National 5 Computing Science): Exam Questions

Exam code: X816 75

29 mins12 questions
1
1 mark

A question in a program requires a true or false response.

State the most suitable data type for storing this response.

2
2 marks

A company runs a sightseeing trip around Iron Craig Island each Saturday and Sunday. Their boat can hold 100 passengers.

Every weekend the available tickets are numbered as follows.

Saturday’s ticket numbers

1 to 100

Sunday’s ticket numbers

101 to 200

A program is being developed to:

  • allow the company to check the validity of each passenger’s ticket as they board the boat

  • calculate and display the total number of the passengers on each trip.

The program design is shown below.

Flowchart for daily ticket analyser programme. It sets passenger count, checks ticket range, processes tickets, and updates or refuses tickets based on validity.

The total number of passengers is set to 0.00 in the design.

State a more appropriate data type to store the total number of passengers. Give a reason for your answer.

Data type................................................................................................

Reason.....................................................................................................

3
2 marks

A program is required for passengers to book a ticket on a bus.

Passengers must enter their destination and their age when making a booking, as some will qualify for free travel.

Complete the table below to state the most suitable data types that should be used.

Variable name

Sample data

Data type

passengerAge

78

destination

Ullapool

4
1 mark

A new supermarket self‑service till is being designed for customers. Part of the program design is shown below.

Checkout counter in a supermarket featuring a conveyor belt, digital screen, card reader, and scanner; shelves with products in the background.
Flowchart of a checkout process: add items to conveyor belt, scan item, add price to total, check if belt is empty, then display total if empty.

State the most suitable data type for the variable that will be used in the ‘is conveyor belt empty?’ step.

5
2 marks

In an archery game, players score points when they hit the target.

The points entered are whole numbers in the range 0 to 10.

The game has 10 rounds and each player shoots two arrows in each round.

The program below is written to record a player’s score.

…
Line 24 SET totalScore TO 0.00
Line 25 SEND "round1" TO DISPLAY
Line 26 RECEIVE arrow1 FROM (REAL) KEYBOARD
Line 27 RECEIVE arrow2 FROM (REAL) KEYBOARD
Line 28 SET roundTotal1 TO arrow1 + arrow2
Line 29 SET totalScore TO totalScore + roundTotal1
…
Line 70 SEND "round10" TO DISPLAY
Line 71 RECEIVE arrow19 FROM (REAL) KEYBOARD
Line 72 RECEIVE arrow20 FROM (REAL) KEYBOARD
Line 73 SET roundTotal10 TO arrow19 + arrow20
Line 74 SET totalScore TO totalScore + roundTotal10
Line 75 < display all ten round totals >
Line 76 SEND "TotalScore: " & totalScore TO DISPLAY

A tester enquired why the total score was displayed as below:

Total score: 180.60

Explain the problem with the program that this output has highlighted.

6
2 marks

A confectionery company requires a program to store information about boxed chocolates.

Open box of assorted chocolates with a decorative lid featuring stars and swirls, revealing individually wrapped chocolates inside.

Complete the table below to state which types of variable should be used.

Variable

Type of variable

chocolateName

inStock

Boolean

numberOfChocolatesInBox

7
1 mark

A competition was run to suggest names for a new bridge. The 20 most popular bridge names have been identified and stored.

State the most suitable data structure used to store the bridge names

8
1 mark

The program code below protects the rechargeable battery in an electric toothbrush.

…
Line 67 SET brushstop TO FALSE
Line 68 WHILE brushstop = FALSE DO
Line 69 SET battery TO <percentage of power left>
Line 70 SET temperature TO <temperature of battery>
Line 71 IF battery < 3 OR temperature > 45 THEN
Line 72 SET brushstop TO TRUE
Line 73 END IF
Line 74 END WHILE
Line 75 <switch toothbrush off>
…

Describe the purpose of the Boolean variable in this code.

9
2 marks

A 9-hole golf course is introducing an app to replace paper scorecards. The total score is the number of times the player hits the ball to complete all 9 holes.

Below is an example of a paper scorecard that a player has filled in.

Golf scorecard for Sanya Abioye on 25/5/2023, with scores for holes 1 to 9 and a total score of 46.

The final scores are stored within the app.

State the most suitable data structure and data type for storing the final score for each hole.

Data structure...............................................................................................

Data type.....................................................................................................

10
2 marks

A club requires a program to calculate how much each member needs to pay in membership fees.

Complete the table below to state which type of variable should be used.

Variable

Sample data

Variable type

membershipFee

37.50

real

yearsOfMembership

6

memberName

Jones

11
5 marks

Tarvit High School is trialling a voting system to decide their representative for the pupil council. A programmer creates a voting app to allow pupils to cast their vote. The winner is displayed once voting is closed.

Voting instructions and current votes for Tarvit High School's 2023 council representative. Lukasz Kowalski is highlighted with 19 votes.

A pupil must enter A, B, C or D to cast their vote.

(i) State the most suitable data type for storing the vote.

[1]

(ii) Using a design technique of your choice, design a solution that will allow only these values to be entered.

[4]

12
8 marks

In a flight booking app, users are asked to enter their departure airport, destination airport, departure date, return date, number of adults and number of children.

A message will then be displayed showing the total flight cost and the duration of the trip.

Passengers are allocated an available seat. A data structure named seats is used to store whether each seat is available (true) or unavailable (false).

Seat allocation chart with numbers 1-60. White boxes indicate available seats, grey boxes indicate unavailable seats. Unavailable: 3, 5, 6, 15, 22, 23, 24, 27, 33, 35, 36.

(i)State the most suitable data structure and data type used to store the seat availability.

[2]

(ii)The following pseudocode design shows how an available seat is allocated.

  • generate a random seat number

  • loop while the generated seat is unavailable

  • generate another random seat number

  • end loop 5 change seat to unavailable

Using a programming language of your choice, write the code required to implement the above design.

[4]

(iii)Explain why the above design becomes less efficient as more passengers are allocated seats.

[2]