0% found this document useful (0 votes)
35 views6 pages

Algorithms Worksheet 1

The document consists of worksheets focused on algorithms and flowcharts, detailing tasks for calculating costs, game scores, and dice game mechanics. It includes flowchart designs for algorithms that prompt user input, calculate totals, and display scores based on game rules. Additionally, it provides examples and tasks for students to complete, including pseudocode writing for the described algorithms.

Uploaded by

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

Algorithms Worksheet 1

The document consists of worksheets focused on algorithms and flowcharts, detailing tasks for calculating costs, game scores, and dice game mechanics. It includes flowchart designs for algorithms that prompt user input, calculate totals, and display scores based on game rules. Additionally, it provides examples and tasks for students to complete, including pseudocode writing for the described algorithms.

Uploaded by

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

Worksheet 1 Algorithms and flowcharts

Unit 7 Algorithm design and programming

Worksheet 1 Algorithms and flowcharts

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

the cost of meal?”

input end

MealCost

output what is output “total is” + total

the cost of drink

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

Total= Total + Count

Is totsl > 500

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.

The flowchart for the game is shown below.

Start

Time = 0

A
balloonScore = 0

Display new balloon

Balloon Yes balloonScore=


touched? C balloonScore+1

No
Display new balloon

B
Yes
Time <60?
D

No

Output “your balloon

score is” , BaloonSCore

3
Worksheet 1 Algorithms and flowcharts
Unit 7 Algorithm design and programming

(a) Complete the statement at A.


(b) Complete the statement in B.
(c) Complete the statement at C.
(d) Complete connector D.
(e) Add a flowchart box at the bottom of the flowchart to display the player’s score.

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

die1, die2 and Yes score = die1 + die2 +


die3 equal? die3

No

Are two of the No


score = 0
dice equal?

Yes

score = sum on two


equal dice

score = score - sum on


third die

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.

(a) Describe the rules of the game.

Start

Die1 = Random(1,6)

Die2 = Random(1,6)

Yes
Die1=Die2? Score = 0

No

Score = Score + Die1


+ Die 2

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

 Write the corresponding pseudocode for the flowchart in Task 1 (b)


 Write the corresponding pseudocode for the flowchart in Task 3 (a)
 Write the corresponding pseudocode for the flowchart in Task 4(a)

You might also like