2.1 Tutorial Note (B) & (D)
2.1 Tutorial Note (B) & (D)
Problem Analysis:
Pseudocode Flowchart
Start
Input base, height
Calculate parallelogram area
parallelogram area = base x height
Display parallelogram area
Stop
2
2.1 (b) & (d): Design a Solution - [SEQUENCE – Example 2]
Problem Statement: Calculate total price for a set of meal after 6% government tax & 10% service tax.
Problem Analysis:
Pseudocode Flowchart
Start
Input price
Calculate new price
3
2.1 (b) & (d): Design a Solution - [SEQUENCE – Example 3]
Problem Statement: Calculate and display the overtime pay received by an employee. Overtime rate is RM5 per
hour.
Problem Analysis:
Pseudocode Flowchart
Start
Input hour
Calculate overtime pay
4
2.1 (b) & (d): Design a Solution - [SELECTION – IF]
Problem Statement: If student’s mark is greater than or equal to 60, Print message “Passed”.
Problem Analysis:
Pseudocode Flowchart
Start
Input mark
if mark ≥ 60
Print "Passed"
end if
Stop
False
True
5
2.1 (b) & (d): Design a Solution - [SELECTION – IF-ELSE]
Problem Statement: If student’s mark is greater than or equal to 60, Print message “Passed”, else Print message
“Failed”.
Problem Analysis:
Pseudocode Flowchart
Start
Input mark
if mark ≥ 60
Print "Passed"
else
Print "Failed"
end if False
Stop
True
6
2.1 (b) & (d): Design a Solution - [SELECTION – MULTIPLE IF-ELSE]
Problem Statement: Check whether a number entered by user is positive, negative or zero. Display an appropriate
message as output.
Problem Analysis:
Pseudocode Flowchart
Start
Input number
if number > 0
Print "Positive"
else if number < 0
True
Print "Negative"
else
end if
Stop True
False
7
2.1 (b) & (d): Design a Solution - [REPETITION – EXAMPLE 1]
Problem Analysis:
Pseudocode Flowchart
Start
Set counter = 1
while counter ≤ 4
Input weight and height
Calculate BMI: True
BMI = weight ÷ (height x
height)
Display BMI False
counter = counter + 1
end while
Stop
8
2.1 (b) & (d): Design a Solution - [REPETITION – EXAMPLE 2]
Problem Statement: Calculate the BMI for 3 persons. Print “Please reduce your weight” if BMI is greater or equal to
25.0. If not, print “You have an ideal weight”.
Problem Analysis:
Pseudocode Flowchart
Start
Set counter = 1
while counter ≤ 3
weight”
else
False
Display “You have an ideal
weight”
True
end if
counter = counter + 1
end while
Stop
9
2.1 (b) & (d): Design a Solution - [REPETITION – EXAMPLE 3]
Problem Analysis:
Pseudocode Flowchart
Start
Set counter = 9
Set sum = 0
while counter ≤ 15
sum = sum + counter True
counter = counter + 2
end while
False
Display sum
Stop
10
2.1 (b) & (d): Design a Solution - [REPETITION – EXAMPLE 4]
Problem Statement: Calculate and print the sum of several integers. Continue reading values until sentinel -99 is
read.
Problem Analysis:
Pseudocode Flowchart
Start
Set sum = 0
Input num
while num ≠ - 99
False
11