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.7
The Home Route Gateway 42 0.4
Freezing 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.nextLine
movieCount = 0

loop for index = 0 to movieList.length-1

if movieList[index].studio = targetStudio

add 1 to movieCount

end if
end loop

open file "studioTotal.txt"
write targetStudio, movieCount to file
close 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.
Declare, using pseudocode or a language with which you are familiar, a variable that can store the data for 1000 books.

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.
The temperature statistics feature displays the message:
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”.

2016 q15


Tony has added a record structure to his program.
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.
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).
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).


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.