Deja - Learner Lesson Workbook
Deja - Learner Lesson Workbook
Starter | 10 Minutes
Steps to Play:
1. Choose your lucky number(s): Select one or more numbers from the
range of 1 to 36.
CONSTANT MIN_BET = 1
CONSTANT MAX_NUMBER = 36
CONSTANT WINNING_MULTIPLIER = 36
REPEAT
wager = 0
winningNumber = 0
REPEAT
INPUT input
IF input == 0 THEN
BREAK
ELSE
END IF
ELSE
REPEAT
INPUT wager
END IF
PRINT "Sorry, the winning number was " + winningNumber + ". Better luck next time!"
END IF
END IF
INPUT playAgain
END
Mr Johnson
Candidate Candidate
forename surname
INSTRUCTIONS TO CANDIDATES
• Write your name, centre number and candidate number in the boxes above. Please write clearly and in capital letters.
• Use black ink. HB pencil may be used for graphs and diagrams only.
• Answer all the questions, unless your teacher tells you otherwise.
• Read each question carefully. Make sure you know what you have to do before starting your answer.
• Where space is provided below the question, please write your answer there.
• You may use additional paper, or a specific Answer sheet if one is provided, but you must clearly show your candidate number,
centre number and question number(s).
Page 5 of 13
1. CTS town is holding an election with three candidates (A, B and C). An electronic voting booth will be
used to allow people to vote.
BEGIN
DECLARE A,B and C as string
DECLARE vote, voters_a, voters_b, voters_c, total_votes as integer
WHILE TRUE do
Print “Please enter a vote”
Read vote
IF VOTE == ‘END’
Break
IF vote == A THEN
A = voters_a + 1
ELSE
IF vote == B THEN
B = voters_b + 1
ELSE
IF vote == C THEN
C = voters_c + 1
ENDIF
total_votes = voters_a + voters_b + voters_c
ENDWHILE
Print “The number of votes for each candidate”, voters_a, voters_b, voters_c
Print “The total number of votes”, total_votes
STOP
[6]
Page 6 of 13
2(a). A computer program calculates the correct dose in grams of a type of medicine.
Use the flow diagram to calculate the correct dose of medicine for a male aged 30.
Dose = 2 x 0.5
=1
[3]
Page 7 of 13
(b). Use the flow diagram to calculate the correct dose of medicine for a pregnant female aged 19.
You must show your working.
= 1.5
[4]
3(a). Jim is writing a program to calculate the wages of workers in a teddy bear factory.
Here is the algorithm used to calculate whether a worker should get a bonus.
State the value of Pay after this code is executed for each of the following values of WagesEarned.
Page 8 of 13
(b). The wages earned by a worker is either $2 for every teddy bear they have made or $5 for every
hour they have worked, whichever is larger.
● allows the user to input the number of teddy bears made and the number of hours worked
● calculates the wages for the number of teddy bears made
● calculates the wages for the number of hours worked
● outputs the larger of the two results.
BEGIN
Read teddybear_num
Read hours_worked
wages_teddybear = teddybear_num * 2
ELSE
ENDIF
STOP
[6]
Page 9 of 13
4. A free drinks machine in an office provides 20 different drinks.
The machine has a small keypad with keys 0 to 9, OK and CANCEL. It also has a small LCD screen,
which can display a short message.
To get a drink, users select an item number between 1 and 20 with the keypad and confirm their choice
by pressing OK. If they make a mistake they can press the CANCEL button and start again. If the
selection is valid and the drink is available it dispenses the drink. The display screen is used to show
suitable short messages throughout the process.
● ON GOODNOTES DOCUMENT
[6]
5 (a). Johnny is writing a program to create usernames. The first process he has developed is shown in
the flowchart in Fig. 1.
Page 10 of 13
For example, using the process in Fig. 1, Tom Ward's user name would be TomWa.
State, using the process in Fig. 1, the username for Rebecca Ellis.
Ans: REBEL
[1]
(b). Johnny has updated the process used to create usernames as follows:
● If the person is male, then their username is the last 3 letters of their surname and the first 2 letters
of their first name.
● If the person is female, then their username is the first 3 letters of their first name and the first 2
letters of their surname.
• What would be the username for a male called Fred Biscuit using the updated process?
Page 11 of 13
Ans: UitFr
[1]
• Write an algorithm for Johnny to output a username using the updated process.
● ON GOODNOTES DOCUMENT
[6]
6. Joseph is an author and programmer, and he needs to estimate how many pages his new book will
have.
Each page has an average of 300 words. Each chapter starts with a chapter title page.
The number of pages is estimated by;
Joseph uses the algorithm below to estimate the number of pages, but his algorithm does not give the
correct result.
01 INPUT numberOfWords
02 INPUT numberOfChapters
03 CONST wordsPerPage = 300
04 numberOfPages = RoundDown(numberOfWords / wordsPerPage)
05 numberOfPages = numberOfWords + numberOfChapters
06 OUTPUT numberOfPages
Joseph has used a RoundDown function to remove the decimal part of the division, e.g.
RoundDown(6.2) would return 6, RoundDown(7.8) would return 7.
[1]
Page 12 of 13
END OF QUESTION PAPER
Page 13 of 13