0% found this document useful (0 votes)
24 views13 pages

Deja - Learner Lesson Workbook

The document outlines a lesson on problem-solving with computers, featuring a game called Cash Pot where players select numbers and wager money. It includes pseudocode for various tasks such as calculating discounts at a swimming center, managing an election voting system, and determining wages for workers. Additionally, it presents algorithms for estimating book pages and creating usernames based on gender.

Uploaded by

jarrdeja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
24 views13 pages

Deja - Learner Lesson Workbook

The document outlines a lesson on problem-solving with computers, featuring a game called Cash Pot where players select numbers and wager money. It includes pseudocode for various tasks such as calculating discounts at a swimming center, managing an election voting system, and determining wages for workers. Additionally, it presents algorithms for estimating book pages and creating usernames based on gender.

Uploaded by

jarrdeja
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 13

zLesson Topic |Problem-solving with Computers

Starter | 10 Minutes

October 12, 2024

Cash Pot is a simple and quick game, where players


select a lucky number from a pool of numbers 1 to
36. The minimum bet is $10. Players win $280 for
every $10 wagered, which equals 26 times the
amount wagered.

Steps to Play:

1. Choose your lucky number(s): Select one or more numbers from the
range of 1 to 36.

2. Select your wager amount: The minimum bet is $10.

3. Players win if their chosen number matches the randomly selected


number drawn during the live draw.

The following algorithm attempts to achieve the requirements of the problem,


however there are several issues with the algorithm. Trace and examine the
algorithm closely and highlight areas where the algorithm’s design will not
achieve the requirements of the program.

CONSTANT MIN_BET = 1

CONSTANT MAX_NUMBER = 36

CONSTANT WINNING_MULTIPLIER = 36

DECLARE selectedNumbers AS LIST OF INTEGERS

DECLARE wager AS REAL

DECLARE winningNumber AS INTEGER

DECLARE input AS INTEGER

DECLARE playAgain AS STRING


BEGIN

REPEAT

wager = 0

winningNumber = 0

REPEAT

PRINT "Enter a lucky number (1-36), or 0 to finish: "

INPUT input

IF input == 0 THEN

BREAK

ELSE IF input >= 6 AND input <= MAX_NUMBER THEN

ADD input TO selectedNumbers

ELSE

PRINT "Invalid number. Please choose between 1 and " + MAX_NUMBER

END IF

END REPEAT IF FALSE

IF selectedNumbers IS EMPTY THEN

PRINT "No numbers selected. Game cancelled."

ELSE

REPEAT

PRINT "Enter your wager amount”

INPUT wager

IF wager < MIN_BET THEN

PRINT "Minimum bet is $" + MIN_BET + ". Please try again."

END IF

UNTIL wager >= MIN_BET

winningNumber = RANDOM_INTEGER_BETWEEN(1, MAX_NUMBER)

IF winningNumber IN selectedNumbers THEN

DECLARE payout AS REAL = wager * WINNING_MULTIPLIER

PRINT "Congratulations! The winning number is " + winningNumber

PRINT "You've won $" + payout


ELSE

PRINT "Sorry, the winning number was " + winningNumber + ". Better luck next time!"

END IF

END IF

PRINT "Would you like to play again? (yes/no): "

INPUT playAgain

UNTIL playAgain != "yes"

PRINT "Thank you for playing Cash Pot!"

END

Collaborative Task - Complete this task together with the class


A local swimming centre offers the following discounts:

1. Members who are aged between 13 and 15 receive a 30% discount.


2. Members who are aged between 16 and 17 receive a 20% discount.
3. Members who are aged 50 and over receive a 40% discount.
4. All other members receive no discount.

Create an algorithm using Pseudocode for the above actions.

Suggested Pseudocode Statements


Arithmetic Operations Decisions Repetition
>= BEGIN / END IF -
<= INPUT ELIF
AND , OR OUTPUT ELSE
=
Chippy Tutoring Services
Computer Science
Problem-solving with Computers

Mr Johnson

Please note that you may see slight differences


between this paper and the original.
Duration: 1hr 15mins

Candidate Candidate
forename surname

Centre number Candidate number

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).

INFORMATION FOR CANDIDATES


• The quality of written communication is assessed in questions marked with either a pencil or an asterisk. In History and Geography
a Quality of extended response question is marked with an asterisk, while a pencil is used for questions in which Spelling, punctuation
and
grammar and the use of specialist terminology is assessed.
• The number of marks is given in brackets [ ] at the end of each question or part question.
• The total number of marks for this paper is 36.
• The total number of marks may take into account some 'either/or' question choices.

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.

Write an algorithm that:

• Allows voters to enter either A, B or C.


• Keeps track of how many times each candidate has been voted for.
• As soon as one person has finished voting, allows the next person to vote.
At any point allows the official to type in “END”, which will print out the number of votes for

each candidate and the total number of votes overall.

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.

The algorithm used is shown by the flow diagram below.

Use the flow diagram to calculate the correct dose of medicine for a male aged 30.

You must show your working.

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.

Workers sometimes get a £50 bonus.

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.

WagesEarned = 50 Pay = ..........50..................

WagesEarned = 200 Pay = ...........250...............


[2]

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.

Write an algorithm that:

● 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

Declare hours_worked and teddybear_num as integer

Declare wage_teddybear and wages_hoursworked as real

Print “Enter the number of teddy bears made”

Read teddybear_num

Print “Enter the number of hours worked”

Read hours_worked

wages_teddybear = teddybear_num * 2

wages_hoursworked = hours -worked * 5

IF wages_teddybear > wages_hourworked THEN

Print “Your wage is”, wages_teddybear

ELSE

Print “Your wage is”, wages_hoursworked

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.

Write an algorithm for the process described above.

The quality of written communication will be assessed in your answer.

● 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;

● dividing the number of words by 300


● ignoring the decimal part of the division
● adding the number of chapters to this total.

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.

State whether this algorithm uses selection, sequence or iteration.


ANS; This algorithm uses sequence

[1]

Page 12 of 13
END OF QUESTION PAPER

Page 13 of 13

You might also like