Page 9 - KMK PREPSPM2 1819 ANSWER
P. 9
SULIT No. Matrik…………………………………….… No. Kad Pengenalan………………………….. SC015
(b) Pseudocodes and flowcharts are used to represent steps in solving a problem.
(i) Create a flowchart to solve the following problem.
“A student will not be fined if he returns the books he borrowed from
a library within 14 days. Otherwise, he will be charged a fine of 30
cents per book for each day of late return. Calculate and display the
amount of fine that a student has to pay, or display a message “Thank
you for early return”.
[4 marks]
(ii) Create a pseudocode to solve the following problem.
“The counselor of a camp would like to know the average age
of those attending a camp, and the oldest age of participants.
The number of people attending a camp will be determined at
the start of the program.”
[4 marks]
Start
Input n, age
Max=age, total=age, c=0
While c < n-1
Input age
If age>max
Max=age
Total=total+age
c=c+1
endwhile
print max, total
End
9 SULIT

