0% found this document useful (0 votes)
94 views8 pages

KMS Gempur PSPM

The document contains a multi-part question assessing programming skills. It includes questions on problem solving steps, pseudocode, flowcharts, Java code snippets, methods, and writing a complete Java program to analyze blood pressure data.

Uploaded by

naderaqistina23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
94 views8 pages

KMS Gempur PSPM

The document contains a multi-part question assessing programming skills. It includes questions on problem solving steps, pseudocode, flowcharts, Java code snippets, methods, and writing a complete Java program to analyze blood pressure data.

Uploaded by

naderaqistina23
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

Untuk Kegunaan Pemeriksa

GEMPUR PSPM
SC025 No. Soalan Markah

SESI 2021/ 2022 1 11

KOLEJ MATRIKULASI SELANGOR 2 15

3 29
Name : _________________________________
4 15
Tutorial : ___________________________
Jumlah

ANSWER ALL QUESTIONS.


1. In order to solve a programming problem, the programmer needs to follow the correct
problem solving steps. This is to ensure that no errors occur while the program is being run.

a) What is problem solving? [2 marks]


_______________________________________________________________________
_______________________________________________________________________

b) List the first two (2) steps in problem solving. [2 marks]


_______________________________________________________________________
_______________________________________________________________________

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.

Ahmad is analysing the process of a


system that his team needs to develop.

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

(b) Given the following Java codes.


int a = 10, b = 5;
while (a <= 50) {
a = a + b; }
System.out.print (a);

(i) State the output(s) based on 3(b). [1 mark]

(ii) Rewrite the code using for loop. [3 marks]

4
c) Rewrite the below Java assignments in the correct version. [3 marks]

char aChar = 5.5;


i.

if (salesAmount >10 &&


ii. <50)

String aName;
iii.
String anotherName;
if (aName == anotherName)

(*assume all the variables have been declared.)

d) What is the output of the following code segments?


(*assume all the variables have been declared.) [3 marks]

Java Statements Output

y = 10;
i.
if (y > 7)
System.out.print ("AAA");
System.out.print ("BBB");

ii for (u = 1; u > 3; u = u+1) {

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]

Give the value of following Java expressions. [2 marks]


ii) false || 6 > 12 && !(3==7)

______________________________________________________________

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);

ii) Write Java statement(s) to accomplish the following process. [2 marks]

Declare a and b as integer variables. Then, initialize a to 10 and b to 20.

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]

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy