KMS Gempur PSPM
KMS Gempur PSPM
GEMPUR PSPM
SC025 No. Soalan Markah
3 29
Name : _________________________________
4 15
Tutorial : ___________________________
Jumlah
c) Identify the steps in problem solving which involve in the situation. [3 marks]
Test the system and record all the problem
found.
The design of pseudocode and flowchart.
d) In your opinion, why should the program be tested before delivering it to the user?
[2 marks]
_______________________________________________________________________
_______________________________________________________________________
1
e) Justify one (1) importance of algorithm in problem solving. [2 marks]
_______________________________________________________________________
_______________________________________________________________________
2. a) KMS’s Bookstore is doing a End Year sales promotion. Total price will be calculated
based on quantity and price of the items. if a customer purchases above RM15.00, the
customer will be given 15% discount. Otherwise, 5% discount will be given. Calculate
the price that a customer should pay.
Based on the given scenario, design the algorithm by using a pseudocode. [7 marks]
2
b) Draw a flowchart to solve the following problem:
Display multiplication numbers of 3 from 50 to 300 and add the total of the numbers.
Display the total added numbers. [8 marks]
3
3. (a) Write Java assignment statements for the following algebraic equations.
(i) y = ax2 + bx + c [2 marks]
𝑛 (𝑛 + 1) 2
(ii) 𝑑 =( ) [3 marks]
2
4
c) Rewrite the below Java assignments in the correct version. [3 marks]
String aName;
iii.
String anotherName;
if (aName == anotherName)
y = 10;
i.
if (y > 7)
System.out.print ("AAA");
System.out.print ("BBB");
System.out.print
i (u + " " );
.
}
System.out.print(“### “);
iii. System.out.println(“****”);
System.out.print(“##”);
System.out.print(“/n**”);
5
e) i) Declare and create an object for a class named CalcAverage. [2 marks]
______________________________________________________________
iii) ( 7 % 5) % 4
______________________________________________________________
f) i) Based on the following Java code, the purpose of the Java code is to calculate the sum of
number from 10 to 100 increment by 10. Identify the type of errors and fix the Java code: [2
marks]
int counter = 10;
int sum = 0;
while (counter <=100){
sum = sum + counter;
add 10 to counter;}
System.out.print(“Sum of all
number is”+sum);
6
iii) Write a Java program segment for :
A Method named calcNumbers that will accept two integer numbers and return the
product value if both numbers are odd, return the total value if both numbers are
even or return the division value if both numbers are not odd or even. [6 marks]
4. Blood pressure reading basically has two numbers, for example 125/85 mmHg. The top
number (125) is called systolic while the bottom (85) is called diastolic. Based on these
reading, the level of blood pressure of a person can be determined, such as low, ideal, pre-
high or high.
Write a complete Java program that performs the following tasks:
Request the reading of blood pressure for systolic and diastolic for n persons. Store
the data in the arrays named arrSystolic and arrDiastolic respectively.
Find minimum reading of diastolic.
Count the number of person that can be categorized as low blood pressure where the
reading of systolic is less than 100 and diastolic is less than 60.
7
[15 marks]