Algorithms Worksheet 1
Algorithms Worksheet 1
Task 1
(a) Draw a flowchart for an algorithm which calculates how much money a student will need
per week to buy a meal and two drinks each weekday. The user should be prompted to
enter how much a meal costs, how much a drink costs, and then calculate and display
the total required.
start
output what is
input end
MealCost
input total=((2*DrinkCost)+1)*7
DrinkCost
(b) Draw a flowchart for an algorithm which calculates how many numbers 1, 2, 3…n have
to be added to reach a total greater than 500. Output the answer n.
1
Worksheet 1 Algorithms and flowcharts
Unit 7 Algorithm design and programming
Start
total=0
Count=0
Count = Count+1
Output Count
End
Task 2
2
Worksheet 1 Algorithms and flowcharts
Unit 7 Algorithm design and programming
Jasmine plays a game on her computer screen. A moving balloon appears on the screen, and
she has to pop the balloon by clicking on it with the mouse. When the balloon is popped another
one appears. The aim of the game is to pop as many balloons as possible in one minute.
Start
Time = 0
A
balloonScore = 0
No
Display new balloon
B
Yes
Time <60?
D
No
3
Worksheet 1 Algorithms and flowcharts
Unit 7 Algorithm design and programming
Task 3
Michael is writing a program for a dice game played with three dice.
(a) The player rolls the dice and is given points according to the following algorithm.
Start
No
Yes
End
4
Worksheet 1 Algorithms and flowcharts
Unit 7 Algorithm design and programming
State the value of the scores if the dice rolled are:
2, 4, 6 = 0
5, 5, 1=9
4, 4, 4= 12
(c) Some rolls of the dice produce a negative score. State a set of three numbers that can
be used to test whether the algorithm produces a negative score when it should and
state the expected output of your test data.
2,2,6=-2
Task 4
James is writing a program to simulate a dice game. The function Random (1,6) generates
a number beween 1 and 6. He has drawn a flowchart to represent the algorithm to
calculate a player’s score when it is their turn. Paul and Coleen play the game.
Start
Die1 = Random(1,6)
Die2 = Random(1,6)
Yes
Die1=Die2? Score = 0
No
Yes
Another go?
No
Output Score 5
End
Worksheet 1 Algorithms and flowcharts
Unit 7 Algorithm design and programming
Paul rolls the dice 3 times, getting six and two on the first throw, one and four on the second
throw and two and three on the third throw. Coleen also rolls the dice three times, getting five
and six on the first throw, four and six on the second throw, two and two on the third throw.
What are the scores of each player?
Paul=18
Coleen=0
EXTENSION