Skip to content
soln standardAlgorithm
Share
Explore

icon picker
sqa past papers

sample answers

2018 q12

question

The app will have information on the top 100 movies of all time including the studio that made the movie, fan ratings and takings at the box office.
For example
Title Studio Rating (out of 100) Takings ($m)The Matrice Nightworks 85 6.7The Home Route Gateway 42 0.4Freezing Aurora 95 12.5.... ..... ...... ......

record format

Using pseudocode or a programming language of your choice, define a suitable record data structure for the movie data above.
class movie { String title = "" String studio = "" int rating = 0 double takings = 0.0}

record variable (array)

Using pseudocode or a programming language of your choice, declare the variable which can store the details of the top 100 movies.
Your answer should use the record data structure created in part (i).
movie[] movieList = new movie[100]

algorithm (count)

Using pseudocode or a programming language of your choice, write an algorithm which:
• asks for a studio name
• totals the number of movies that the studio has in the top 100
• saves the studio name and total to file.
targetStudio = keyboard.nextLinemovieCount = 0
loop for index = 0 to movieList.length-1
if movieList[index].studio = targetStudio
add 1 to movieCount
end ifend loop
open file "studioTotal.txt"write targetStudio, movieCount to fileclose file

2017 q9


A programmer is creating a program to store details about books. The details stored are: title, author, number of pages and price.
Create, using pseudocode or a language with which you are familiar, a record structure to store the book details.
class book { String title = "" String author = "" int pages = 0 double price = 0.0}
Declare, using pseudocode or a language with which you are familiar, a variable that can store the data for 1000 books.
book[] bookList = new book[1000]

2017 q10


A sensor measures the temperature in a room at the start of each hour in a day. These temperatures are stored in an array called temps.
index | 0 | 1 | 2 | 3 | ....... | 22 | 23 | temps | 10 | 8 | 12 | 11 | ....... | 14 | 13 |
The temperature statistics feature displays the message:
The lowest temperature was 8 Celsius at hour 1.
Write, using pseudocode or a language with which you are familiar, an algorithm that can:
• find the lowest temperature
• display the message shown above
• write the lowest temperature to an external file called “low.txt”.
minTemp = temps[0]minTempPosition = 0
loop for index = 1 to temps.length-1
if temps[index] < minTemp
minTemp = temps[index] minTempPosition = index
end ifend loop
display "The lowest temperature was " + minTemp + "Celsius at hour " + minTempPosition
open file "low.txt"write minTempclose file

2016 q15


Athlete DataForename SalmaSurname HussainRunner number 324Professional TrueSeason best 45·12Weight (kg) 67·5
Tony has added a record structure to his program.
RECORD athleteData IS { STRING forename, STRING surname, INTEGER runnerNumber, BOOLEAN professional, REAL seasonBest, REAL weight}
Tony wants to store his eight athletes’ data using the record structure shown above. The variable name is athletes.
Using pseudocode, or a programming language of your choice, declare the variable which can store the data for the eight athletes.
athleteData[] athleteList = new athleteData[8]
Using pseudocode, or a programming language of your choice, write the code necessary to add the data for the athlete Salma shown in the table above. Your answer should use the variable declared in part (a).
athleteList[0] = new athleteData("Salma", "Hussain", 324, True, 45.12, 67.5)
Tony wants to find the fastest 400 m time of the season.
Using pseudocode, or a programming language of your choice, design an algorithm to find the fastest season time. Your answer should use the variable declared in part (a).
minTime = athleteList[0].seasonBestminTimePosition = 0
loop for index = 1 to athleteList.length-1
if athleteList[index].seasonBest < minTime
minTime = athleteList[index].seasonBest minTimePosition = index
end ifend loop
display minTime


Want to print your doc?
This is not the way.
Try clicking the ⋯ next to your doc name or using a keyboard shortcut (
CtrlP
) instead.