0% found this document useful (0 votes)
3 views

class assignment

The document presents two examples of pseudocode for different scenarios. The first example involves rolling a die in a game of Ludo until a six is rolled, allowing the player to move a piece. The second example calculates the wages of five workers based on their hours worked and rate of pay using a FOR loop.

Uploaded by

Chisaki
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)
3 views

class assignment

The document presents two examples of pseudocode for different scenarios. The first example involves rolling a die in a game of Ludo until a six is rolled, allowing the player to move a piece. The second example calculates the wages of five workers based on their hours worked and rate of pay using a FOR loop.

Uploaded by

Chisaki
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/ 2

Example 1: A game of Ludo is being run and you must roll a six (6) to be able to start the game.

Let the user roll numbers between 1 and 5 until they have rolled a six. When a 6 is rolled, tell
the user that they can move a piece.

Ipo:
Input Process Output
Num1 Check if number is 6
If number is 6 “You can move your piece”
Else number is 6 “Rerolling”

Pseudocode:

Start:
Declare num1, roll as integer
Display “What number did u roll”
Input num1
Input roll = 6
Loop until ‘roll’ is true
If num1<roll = false
Display “Rerolling”
else num>roll = true
Display “You can move your piece”
End

Trace Table:

Row Number Roll


3 - -
3 - -
3 3 False
4 - -
5 6 True

Example 2: A company wants a program to calculate the wages for their five (5) workers. The
wage is equal to the rate of pay (rate) multiplied by the amount of hours worked (hrs). Utilize a
FOR loop for this question.

Ipo chart:

Input Process Output


rate Wage= rate * hrs Wages of each worker
hrs

Pseudocode:
Start:
Declare hrs, rate, wage as integer
Display “What are the hours of the 5 workers together”
Input hrs
Display “What is the rate the 5 workers worked at”
Input rate
Wage= hrs * rate
Display “This is the wage of all workers” & wage

Trace table:

Row Rate Hours Wage


1 - - -
2 - - -
3 20 5 100
4 20 5 100
5 20 5 100

You might also like