Pseudocode Worksheet 1 Answer
Pseudocode Worksheet 1 Answer
INPUT Name
OUTPUT “Hello “ + Name
MEALCOST <- 10
MEALSELLINGPRICE <- 2 * MEALCOST
TAX <- MEALSELLINGPRICE * 0.06
TOTALPRICE <- MEALSELLINGPRICE + TAX
4. Design a program that asks a user to INPUT two numbers. The program will multiply the
numbers together (hint: you need to create a variable that stores the product). If the
product is larger than 100 it outputs the message “Greater than 100”. If not, it does nothing.
INPUT N1
INPUT N2
Product <- N1 * N2
IF Product > 100
THEN
OUTPUT “Greater than 100”
1
Pseudocode Practice
(Do not use CASE OF, use IF ... ELSE ... THEN instead)
You are asked to design a program that can automatically calculate the cost of the
purchase. Print out the cost. The program will keep repeating until a user INPUT a
value "stop". Write the pseudocode for this program.
IF NumberOfFries > 10
THEN
IF NumberOfFries > 20
THEN
Discount <- 0.15
ELSE
Discount <- 0.05
ENDIF
ELSE
Discount <- 0
ENDIF
INPUT Continue
2
Pseudocode Practice
1. Totaling
StudentMark [1:10]
70 75 80 60 70 65 75 90 95 100
Total <- 0
ClassSize <- 10
FOR Counter <- 0 TO 10
Total <- Total + StudentMark[Counter]
NEXT
2. Counting
StudentMark [1:10]
70 75 80 60 70 65 75 90 95 100
Write the pseudocode to find the number of students who pass (mark > 50) the exam.
PassCount <- 0
ClassSize <- 10
FOR Counter <- 0 TO 10
IF StudentMark[Counter] > 50
THEN
PassCount <- PassCount + 1
NEXT