1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
1.0 Problem Solving (SEQUENCE)
1.2 Problem Analysis
Identity input, process, and output from a given problem
1.3 Design a Solution
Define Algorithm and Flowchart
Solve a given problem using Pseudocode
Solve a given problem using Flowcharts
1. Ahmad wants to create a program that determines the total area of a piece of land where
length and width are given.
Input Process Output
width, length Calculate the total area of a piece of land total area
based on width and length given.
Pseudocode Flowchart
Start
Start
Read width , length Read width, length
Total area = width x length
Print Total area
Stop
Total area = width x length
“ Start NOW, Not TOMORROW…” Print Total area
Stop
1
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
2. Calculate and print the volume of a sphere based on the formula given below.
Volume of sphere =
Input Process Output
radius Calculate volume of sphere based on Volume of sphere
radius entered.
Pseudocode
Start
Read radius
Volume of sphere = (4/3) x 3.142 x radius x radius x radius
Print Volume of sphere
Stop
Flowchart
“ Start NOW, Not TOMORROW…”
2
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
3. Convert a measurement in millimeter (mm) to meter (m) and print the result.
Input Process Output
milimeter Calculate measurement in meter based meter
on measurement in milimeter
OR
Calculate meter based on milimeter
Pseudocode Flowchart
Start
Read milimeter
meter = milimeter / 1000
Print meter
Stop
4. A government tax of 10% and service tax of 5% will be added to the price of a set of
meal bought at MFC. Calculate the total price that Ali has to pay for a set of meal.
Input Process Output
price Calculate total price of a set of meal based on Total price
price given.
“ Start NOW, Not TOMORROW…”
3
Pseudocode 1.0 Problem Solving [SEQUENCE]
Start 1.2 Problem Analysis
1.3 Design a Solution
Read price
Gov tax = 0.1 x price Flowchart
Service tax = 0.05 x price Start
Total price = price +Gov tax + Service tax
Print Total price Read price
End
Total price = 1.15 x price
OR
Print Total price
Start
Read price Stop
Total price =1.15 x price
Print Total price
End
“ Start NOW, Not TOMORROW…”
4
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
5. A program that reads two numbers and print their sum and product.
Input Process Output
number1, Calculate sum and product based on Sum,
number2 number1 and number2. Product
Pseudocode Flowchart
Start
Read number1, number2
Sum = number1 + number2
Product = number 1 x number 2
Print Sum, Product
Stop
“ Start NOW, Not TOMORROW…”
5
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
6. Calculate the Body Mass Index (BMI) for a person.
(BMI = weight/(height x height))
Input Process Output
BMI
weight, Calculate BMI based on weight and height
height entered.
Pseudocode Flowchart
Start
Start
Read weight, height Read weight, height
BMI = weight / (height x height ) BMI = weight/ (height x height)
Print BMI
Print BMI
Stop Stop
`
“ Start NOW, Not TOMORROW…”
6
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
7. The second step in programming is designing the solution using algorithm. Define
algorithm.
An algorithm is a step-by-step instruction that will transform the input into the output.
8. Explain two (2) techniques on how an algorithm can be represented.
a. Pseudocode is an artificial, informal language used to develop algorithms which
also similar to everyday English.
b. Flowchart is a graphic representation of the algorithms.
9. Problem solving is a mental process that involves discovering, analyzing and solving
problems.
State the importance of algorithm in problem solving.
Algorithms are a very important topic in Computer Science because they help software
developers create efficient and error free programs.
10. Calculate and print the area and circumference of a circle.
(area = pi x radius x radius, circumference = 2 x pi x radius, where pi = 3.14)
Input Process Output
radius Calculate area and circumference of a circle area, circumference
based on radius entered.
Pseudocode Flowchart
Start
Start
Read radius Read radius
area = 3.14 x radius x radius
circumference = 2 x 3.14 x radius area = 3.142 x radius x radius
Print area, circumference circumference = 2 x 3.14 x radius
End
Print area, circumference
Stop
“ Start NOW, Not TOMORROW…”
7
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
11. Convert the following algorithm into a flow chart.
Start
Read number
square = number x number
Print square
Stop
Flowchart
Start
Read number
square = number x number
Print square
Stop
12. A hotel offers two types of room with different rates.
During the school holidays, the hotel offers 10% discount on the total room charge. You
are going to make a reservation on one Superior room and one Deluxe room for a few
nights. Calculate and display the total room charge that you have to pay.
“ Start NOW, Not TOMORROW…”
8
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
Input Process Output
Number of night Calculate total room charge based on number of Total room charge
night entered by a user.
Pseudocode
Start
Read number of night
room charge = number of night x ( 160 + 180)
discount = 0.1 x room charge
total room charge = room charge – discount
Print total room charge
End
OR
Start
Read number of night
total room charge = 0.9 x (number of night x ( 160 + 180))
Print total room charge
End
Flowchart
Start
Read number of night
total room charge = 0.9 x (number of night x ( 160 + 180))
Print total room charge
Stop
“ Start NOW, Not TOMORROW…”
9
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
13. A factory worker gets a monthly salary based on basic payment and overtime. The basic
payment is RM1, 820.00 and overtime will be paid RM5 per hour. Calculate the monthly
net salary for the factory worker after deducting 12% of KWSP.
Input Process Output
overtime hour Monthly net salary
Calculate monthly net salary based on overtime
hour entered by user.
Pseudocode Flowchart
START Start
READ overtime hour Read overtime hour
Overtime pay = overtime hour x RM5 Overtime pay = overtime hour x RM5
Monthly salary = RM1,820 + overtime pay
Monthly salary = RM1,820 + overtime pay
KWSP = 0.12 x Monthly salary
KWSP = 0.12 x Monthly salary Monthly net salary = Monthly salary - KWSP
Monthly net salary = Monthly salary - KWSP Print Monthly net salary
PRINT Monthly net salary Stop
STOP
OR
START
READ overtime hour
Overtime pay = overtime hour x RM5
Monthly salary = RM1,820 + overtime pay
Monthly net salary = 0.88 x Monthly salary
PRINT Monthly net salary
STOP
“ Start NOW, Not TOMORROW…”
10
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
14. Calculate and display the area of shaded region in the
diagram below.
Input Process Output
A , B, C Area of shaded region
Calculate the area of shaded region based on
A, B and C given.
Pseudocode Flowchart
Start
Start
Read A, B, C Read A, B, C
Area AB = AX B
Area BC = ½ x (B x C) Area AB= A x B
Area of shaded region = Area AB – Area BC Area BC = ½ x ( B x C)
Print Area of shaded region Area of shaded region = Area AB – Area BC
Stop
Print Area of shaded region
Stop
“ Start NOW, Not TOMORROW…”
11
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
15. Create a program that calculates and displays the overtime pay received by an
employee. Overtime rate is RM500 per hour.
Input Process Output
hour Calculate the overtime pay based on hour Overtime pay
entered by the user.
Pseudocode Flowchart
Start
Start Read hour
Read hour
Overtime pay = RM500 x hour Overtime pay = RM500 x hour
Print Overtime pay
Stop
Print Overtime pay
Stop
“ Start NOW, Not TOMORROW…”
12
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
16. Siti is a sales person for a company that sells used computers. The price for Brand A is
RM 500 per unit while Brand B costs RM 1000 per unit. The company will pay her 10%
commission for the total sales where total sale will be calculated based on the number of
computer sold for both brands.
Input Process Output
number of unit Brand Calculate the commission for the total sales commission
A, based on number of unit brand A and
number of unit Brand B.
number of unit Brand
B
Pseudocode Flowchart
Start Start
Read number of unit Brand A, number of
Read number of unit
unit Brand B Brand A, number of
total sale = (number of unit Brand A x
unit Brand B
RM500) + ( number of unit Brand B x
RM1000) total sale = (number of unit Brand A x RM500) +
(number of unit Brand B x RM1000)
commission = 0.1 x total sale
Print commission commission = 0.1 x total sale
Stop
Print commission
Stop
“ Start NOW, Not TOMORROW…”
13
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
17. Ahmad plans to install floor tiles for his car parking spaces which are rectangular in
shape. The price per square feet of floor tiles will be determined after Ahmad chooses
the suitable tiles. Calculate and display the area of Ahmad’s parking space and the total
cost of tiles needed to be paid by him.
Input Process Output
width in feet, Calculate the area and the total cost of tiles area , total cost
length in feet, of Ahmad’s parking space based on width in
price feet, length in feet and
price per square feet.
Pseudocode Flowchart
Start
Read width in feet, length in feet, price
area = width in feet x length in feet
total cost = area x price
Print area, total cost
Stop
“ Start NOW, Not TOMORROW…”
14
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
18. A program will calculate students’ monthly fee for a year.
Input Process Output
Monthly fee Calculate total monthly fee for a year based Total monthly fee
on monthly fee.
Pseudocode Flowchart
Start Start
Read monthly fee Read monthly fee
Total monthly fee = monthly fee x 12
Print total monthly fee
Stop
Total monthly fee = monthly fee x 12
Print total monthly fee
Stop
“ Start NOW, Not TOMORROW…”
15
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
19. A contractor needs a program that calculates and displays the volume of rectangular
swimming pool.
Input Process Output
width, Calculate volume of rectangular swimming pool Volume of rectangular
length, based on width, length and height
height
Pseudocode Flowchart
Start Start
Read width, length, height Read width, length, height
Volume of rectangular = width x length x Volume of rectangular = width x height x length
height
Print Volume of rectangular
Stop
Print Volume of rectangular
Stop
“ Start NOW, Not TOMORROW…”
16
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
20. Convert an amount of money from sen to ringgit.
Input Process Output
Amount in ringgit
amount in sen Calculate amount in ringgit based on amount
in sen entered by user.
Pseudocode Flowchart
Start Start
Read amount in sen Read amount in sen
Amount in ringgit = amount in sen/100 Amount in ringgit = amount in sen / 100
Print amount in ringgit
Print amount in ringgit
Stop Stop
“ Start NOW, Not TOMORROW…”
17
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
21. Study the problem statement below.
Input Process Output
Length, Calculate volume of cuboid based on Length, Volume of Cuboid
Width, Width and Height entered by a user.
Height
Pseudocode Flowchart
Start Start
Read Length, Width, Height Read Length, Width, Height
Volume of Cuboid = Length x Width x Volume of Cuboid = Length x Width x Height
Height
Print Volume of Cuboid Print Volume of Cuboid
Stop
Stop
“ Start NOW, Not TOMORROW…”
18
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
22. Prompt user to input in Kilobyte, and convert the input into Megabyte, Gigabyte,
Terabyte and Petabyte.
Input Process Output
Kilobyte Calculate Megabyte, Gigabyte, Terabyte and Megabyte, Gigabyte,
Petabyte based on Kilobyte entered by a user. Terabyte ,Petabyte
Pseudocode Flowchart
Start 10 Start
Read Kilobyte Read Kilobyte
Megabyte = Kilobyte/2 Megabyte = Kilobyte/210
Gigabyte = Kilobyte / 2 20
Gigabyte = Kilobyte / 2 20 Terabyte = Kilobyte / 2 30
Petabyte = Kilobyte / 2 40
Terabyte = Kilobyte / 2 30
Print Megabyte, Gigabyte,
Petabyte = Kilobyte / 2 40 Terabyte, Petabyte
Print Megabye, Gigabye, Terabyte, Petabyte
Stop Stop
OR
Start
Read Kilobyte
Megabyte = Kilobyte/1024
Gigabyte = Kilobyte / (1024 x 1024)
Terabyte = Kilobyte / (1024 x 1024 x 1024)
Petabyte = Kilobyte / (1024 x 1024 x 1024 x
1024)
Print Megabye, Gigabye, Terabyte, Petabyte
Stop
“ Start NOW, Not TOMORROW…”
19
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
23. The manager of RZX Bookstore plans to promote his bookstore by giving a discount of
15% for each book. Calculate and display the price after discount for one book
purchased.
Input Process Output
price Calculate price after discount based price price after discount
entered by a user.
Pseudocode Flowchart
Start Start
Read price Read price
discount = 0.15 x price Price after discount = 0.85 x price
Price after discount = price - discount
Print price after discount Print price after discount
Stop
Stop
OR
Start
Read price
Price after discount = 0.85 x price
Print price after discount
Stop
“ Start NOW, Not TOMORROW…”
20
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
24. Identify input, process and output to calculate the density of an object using formula.
density = mass / volume.
Input Process Output
mass, Calculate density based on mass and volume density
volume entered by a user.
Pseudocode Flowchart
Start Start
Read mass, volume Read mass, volume
density = mass/volume density = mass/volume
Print density
Print density
Stop Stop
“ Start NOW, Not TOMORROW…”
21
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
25. Calculate and print the sum, average and multiplication of two given numbers.
Input Process Output
number 1, Calculate sum, average and multiplication of two sum, average, multiplication
number 2 numbers based on number 1 and number 2
entered by a user.
Pseudocode Flowchart
Start Start
Read number 1, number 2
sum = number 1 + number 2 Read number 1, number 2
average = (number 1 + number 2)/2
multiplication = number 1 x number 2 sum = number 1 + number 2
Print sum, average and multiplication average = (number 1 + number 2)/2
multiplication = number 1 x number 2
Stop
Print sum, average and
multiplication
Stop
“ Start NOW, Not TOMORROW…”
22
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
26. Sheena lives in Ipoh. She has to commute from Ipoh to Gopeng 5 days a week and have
to pay RM3.20 every time she goes through the toll. Calculate the toll amount to be paid
by Sheena every month. (Assume 1 month = 4 weeks)
Input Process Output
No input Calculate the monthly toll amount to be paid by Monthly toll amount
Sheena based on the given rate.
Pseudocode Flowchart
Start Start
monthly toll amount = RM3.20 x 2 x 5 x 4 monthly toll amount = RM3.20 x 2 x 5 x 4
Print monthly toll amount
Stop
Print monthly toll amount
Stop
“ Start NOW, Not TOMORROW…”
23
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
27. Convert the pseudocode below to flowchart.
Flowchart
Start
Read name, balance, rate
interest = balance x rate
Print name, interest
Stop
“Everyone has the same 24 hours. Some DREAMERS consumes it in DREAMING and some DREAMERS
consumes it in WORKING…”
“ Start NOW, Not TOMORROW…”
24
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
28. Calculate the total amount customer needs to pay for a set of lunch meal and a set of
kid’s meal ordered after 10% sales and service tax (SST) are charged. Display the total
nett price paid based on quantity bought.
Item Price
Lunch Meal RM7.90
Kid’s meal RM5.70
Input Process Output
number of lunch meal, Calculate total net price based on number of total net price
number of kid’s meal lunch and number of kid’s meal entered by a
user.
Pseudocode Flowchart
Start
Start Read number of lunch meal,
Read number of lunch meal, number of kid’s number of kid’s
meal meal
total price = (number of lunch meal x
total price = (number of lunch meal x RM7.90)
RM7.90) + (number of lunch meal x RM5.70) + (number of lunch meal x RM5.70)
total net price = 1.10 x total price
total net price = 1.10 x total price
Print total net price
Stop
Print total net price
Stop
“ Start NOW, Not TOMORROW…”
25
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
29. Read and print two variables Name and Age.
Input Process Output
Name, Display Name and Age based on input entered by Name, Age
Age a user.
Pseudocode Flowchart
Start Start
Read Name, Age Read Name, Age
Print Name, Age Print Name, Age
Stop Stop
“ Start NOW, Not TOMORROW…”
26
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
30. Calculate and display the sum and the average of three numbers.
Input Process Output
number 1, Calculate sum and average based on number 1, sum, average
number 2, number 2 and number 3 entered by a user.
number 3
Pseudocode Flowchart
Start Start
Read number 1, number 2, number 3
sum = number 1 + number 2 + number 3 Read number 1, number 2,
number 3
average = (number 1+number 2+number 3)/ 3
Print sum, average
Stop
sum = number 1 + number 2 + number 3
average = (number 1+number 2+number 3)/ 3
Print sum, average
Stop
“ Start NOW, Not TOMORROW…”
27
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
31. Calculate and display the perimeter of a cuboid.
Input Process Output
length, Calculate perimeter of cuboid based on length, perimeter of cuboid
width, width and height entered by a user.
height
Pseudocode Flowchart
Start Start
Read length, width, height
perimeter of cuboid = 4(length + width + Read width, length, height
height)
Print perimeter of cuboid perimeter of cuboid = 4(length + width +
height)
Stop
Print perimeter of cuboid
Stop
“ Start NOW, Not TOMORROW…”
28
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
32. Calculate and display Ahmad’s age.
Input Process Output
Birth year, Calculate Ahmad’s age based on birth year Ahmad’s age
Current year
and current year entered by a user.
Pseudocode Flowchart
Start Start
Read birth year, current year
Ahmad’s age = current year – birth year Read birth year, current
Print Ahmad’s age year
Stop
Ahmad’s age = current year – birth year
Print Ahmad’s age
Stop
“ Start NOW, Not TOMORROW…”
29
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
33. Calculate the average of three numbers that are randomly inserted by the user.
Input Process Output
number 1, Calculate average based on number 1, number 2 average
number 2, and number 3 entered by a user.
number 3
Pseudocode Flowchart
Start Start
Read number 1, number 2, number 3
Read number 1, number 2,
average = (number 1+number 2+number 3)/ 3
number 3
Print average
Stop
average = (number 1+number 2+number 3)/ 3
Print average
Stop
“ Start NOW, Not TOMORROW…”
30
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
34. You are asked to calculate the area of shaded region of two circles in FIGURE 1.
Input Process Output
r1, r2 Calculate area of shaded region based on r1 and area of shaded region
r2 entered by a user.
Pseudocode Flowchart
Start Start
Read r1, r2
Area r1 = 3.142 x r1 x r1 Read r1, r2
Area r2 = 3.142 x r2 x r2
Area of shaded region = Area r2 – Area r1 Area r1 = 3.142 x r1 x r1
Print area of shaded region Area r2 = 3.142 x r2 x r2
Area of shaded region = Area r2 – Area r1
Stop
Print area of shaded region
Stop
“ Start NOW, Not TOMORROW…”
31
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
35. ABC Supermarket offers 20% discount for each item that is bought during Year End Sale
(YES). The discount and price after discount will be calculated based on the given normal
price. As a result, price after discount will be displayed.
Input Process Output
normal price Calculate price after discount of based on Price after discount
normal price entered by a user.
Pseudocode Flowchart
Start Start
Read normal price Read normal price
discount = 0.2 x normal price Price after discount = 0.8 x normal price
price after discount = normal price -
discount
Print price after discount
Stop
OR
Start Print price after discount
Read normal price Stop
Price after discount = 0.8 x normal price
Print price after discount
Stop
“ Start NOW, Not TOMORROW…”
32
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
36. Problem solving is one of the core activities of computer science. It involves five main
steps.
(a) List the five (5) steps in problem solving.
Problem Analysis, Design a Solution, Implementation, Testing and Documentation
(b) State one (1) main purpose of testing in problem solving.
To ensure the programs runs correctly and is error free.
(c) State two (2) representations of algorithm.
First Problem Analysis
Second Design a Solution
37. Calculate the price of a cup of coffee sold at MyKopitiam Cafe. The price is based on the
number of scoops of espresso coffee, sugar syrup and milk. The prices of espresso coffee,
sugar syrup and milk are RM5, RM3 and RM0.20 per scoop respectively.
Input Process Output
number of scoops of Calculate the price of a cup of coffee based Price of cup of coffee
espresso coffee, on the number of scoops of espresso coffee,
number of scoop of sugar syrup and number
number of scoop of
sugar syrup , of scoop of milk.
number of scoop of
milk
“ Start NOW, Not TOMORROW…”
33
Pseudocode 1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
Flowchart
Start Start
Read number of scoops of espresso coffee,
number of scoop of sugar syrup , Read number of scoops of
number of scoop of milk espresso coffee, number of
scoop of sugar syrup ,
price a cup of coffee = (number of scoops of number of scoop of milk
espresso coffee x RM5) + (number of
scoop of sugar syrup x RM3) + (number price a cup of coffee = (number of scoops of
of scoop of milk x RM0.20) espresso coffee x RM5) + (number of
scoop of sugar syrup x RM3) + (number
Print price a cup of coffee of scoop of milk x RM0.20)
Stop
Print price a cup of coffee
Stop
“ Start NOW, Not TOMORROW…”
34
1.0 Problem Solving [SEQUENCE]
1.2 Problem Analysis
1.3 Design a Solution
38. Meatz Place Café prints a receipt for its customers as shown in FIGURE 2. The unit price
for each item is fixed and stored by the system. The date
and time are automatically generated by the system.
(a) State the inputs required by the system.
Item and quantity
(b) Besides the item, unit price, quantity, date and time,
state the other outputs produced by the system.
Sub total, SST and Total
(c) State two (2) of the process involved to produce the above outputs.
Price = Unit x quantity
Total = Sub total + SST
SST = 0.1 x Sub Total
“ Start NOW, Not TOMORROW…”
35