Professional Documents
Culture Documents
SC025SetPastYear20182022 PDF
SC025SetPastYear20182022 PDF
SC025SetPastYear20182022 PDF
Kelas :
2018/2019 1
2019/2020 6
2020/2021 13
2021/2022 19
PSPM II 2018/2019
Section B
1 (c) Mr Rahman plans to make a reservation for a hotel room in Langkawi Island. The basic rate is
RM250.00 per night and the sales and service charge is 15% of the room rate. Determine the total
payment if he books the hotel room for n nights. List the input, processes involved to calculate the
total payment and the output.
[4 marks]
Input
Process
Output
Read and determine the larger and smaller between two numbers. Print the larger number followed
by the smaller number if they are not equal. Otherwise, print the message – The numbers are equal.
[7 marks]
Display even numbers from 100 to 700 and add the total of the numbes. Display the total sum.
[10 marks]
(a) y = a2 + b2 – 4ac
[3 marks]
2 ( 𝑎2 + 𝑐 2 )+𝑎𝑏
(b) 𝑥 =
√𝑎+𝑐
[4 marks]
(c) Given the following Java codes, determine the value of c and y.
int a = 10, b = 5;
double c = 2, x = 4.2, y = 33, z = 2.0;
c=a+b–x/c;
y = 56 % 5 / 2 + a ;
c = __________________
y = __________________
[6 marks]
int n = 10;
while ( n ___________) {
System.out.print ( _______________ ) ;
(ii) Write Java stements to determine the commisson (comm) based on the sales range given
in the following table.
[6 marks]
[4 marks]
____________________________________________________________________________
____________________________________________________________________________
____________________________________________________________________________
____________________________________________________________________________
____________________________________________________________________________
____________________________________________________________________________
(a) The women long jump competition has n athletes. Each athlete is given two jumps
and the winner is determined based on the longest jump distance (in metre). The
first line of input is n, representing the number of athletes followed by n lines, each
represents the athlete’s identification number, the distance of the first and second
jump. Write a complete Java program to find and print the winning athlete’s
identification number and her winning jump distance.
Section B
1 (a ) A customer can book a flight ticket through an online system. In each trancastion, a customer
has to pay total flight charges based on number of passenge rs and cabin class. Determine input,
process and output for the flight ticket booking problem.
[4 marks]
1 (b) A student is required to determine volume of a cuboid on the measurements of length, width
and height in centimetre unit.
(i) Determine input, process and output for the volume calculation problem.
[5 marks]
(ii) Complete the following Java program to calculate and display the volume with
appropiate message.
[5 marks]
class Cuboid{
public static void main(String[]args ){
double length= 4.5;
double width= 9.3;
double height= 7.8;
double volume;
____________________________________________________
_____________________________________________________
_____________________________________________________
}
SC025 Past Years 2018- 2022 6
1 (c) Write a pseudocode for each of the following scenario.
1 (d) Draw a flowchart with a selection structure to display “Weekend” if an input variable, day is
“Sat” or “Sun”. Otherwise display “Weekdays”.
[8 marks]
2 (b) Write a complete Java progam to dsiplay the conversion result of 28.5 degree Celcius to
Fahrenheit using the following formula.
9
Fahrenheit = degree in Celcius x + 32
5
[6 marks]
[6 marks]
if (n % 5 == 0 )
System.out.println (n);
[3 marks]
3 (b) (ii) Produce output for the java segment in 3 (b) (i)
[5 marks]
4 (b) Write a Java program for a class named MaxClass to find a maximum value from an array. The
class shall contain main and findMax methods.
[11 marks]
1. DG Tech Sdn Bhd is a software development company in Kuala Lumpur, Malaysia. One of their
customers, DIY Mart requests a solution to allow their shoppers to shop online using mobile
applications. As a project manager of DG Tech, you set up a meeting with your team members to kick
off the project.
(a) As a project manager, suggest the appropriate steps in sequence in order to develop the
solution.
[6 marks]
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________
(c) Discuss two (2) benefits of testing step before delivering the system to the customers.
[4 marks]
Mark Grade
80 -100 A
65 - 79 B
50 - 64 C
40 - 49 D
0 - 39 E
[14 marks]
[2 marks]
System.out.print("**** ");
System.out.println("###");
System.out.print("**");
System.out.println("*");
[2 marks]
[4 marks]
(ii) Assume p and q are integer variables. Swap the values of p and q. Declare additional
variables, if necessary.
[4 marks]
num = input.nextInt();
sum = num;
while (num != -1)
{
num = input.nextInt();
sum = sum + num;
}
[4 marks]
3 (f) Write a program segment using for to sum all the multiples of 5 between 1 to 100.
[6 marks]
double A = 0;
for (int x = 3 ; x < 8 ; x = x+1) {
if(x < 4)
A = ( x * x) - 1;
else if (x < 6)
A = 5 + x ;
else
A = 20 - ( x * x );
[5 marks]
4 Write a program that reads number of COVID-19 cases for each of the 14 states in Malaysia
on 31st August 2020 into an array. Based on TABLE 4, the program must determine.
i. The highest number of cases among thte 14 states on the specified day.
ii. The number of cases for each zone ( i.e red zone, yellow zone and green zone)
[15 marks]
1 (a) The wage to mow the yard of a house is based on the price of diesel used to mow it. The yard
to be mowed is shown in the shaded area given in the figure below.
House area
You are given the length and width of the house area and the length and width of the house. The
price of diesel used is Rm2.00 per square meter.
Identify the input. process and output to calculate and display the wage of moving the yard of the
house.
[10 marks]
[4 marks]
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________
__________________________________________________________________________________
(b) Write the Java assignment statements for the following algebraic equations.
(i) 𝑎 = 𝑦 2 𝑥 2 − 𝑦 + 2𝑥𝑦
[2 marks]
__________________________________________________________________________________
__________________________________________________________________________________
(ii) 𝑏 = √2𝑥 + 12 − 2𝑥
[2 marks]
__________________________________________________________________________________
__________________________________________________________________________________
int a = 3, c = 15;
double b = 0.5, d = 15 * b;
System.out.println(c % a – a % c);
System.out.println(4 * d / (b / a));
System.out.println((25 - c) / b * 13 + (-5));
[6 marks]
import java.util.Scanner;
System.out.print(“*”);
Modify the above program such that it displays a line with asterisks ”*” in even position and dashes ‘-
‘ in odd position. Output sample of the modified java program is as shown in figure below
-*-*-*-*-
[5 marks]
Code segment A – This segment evaluates whther the given body temperature (in Celcius) is between
35.0 (inclusive) and 38 (inclusive). If the value entered is not between this range, it will display “Invalid
value. Enter body temperature again : ”. Use an appropriate control structure to repeat this input
validation until the user enters a valid value.
Code segment B- This segment evaluates the Boolean input for variables cough, runnyNose, and
soreThroat. Use appropriate control structure to evaluate the variables. If all of them are false, it will
display “free from COVID-19”, otherwise it will display :Must be quarantined”.
Complete the following Java code segments that evaluates four (4) input values from a user
[10 marks]
import java.util.Scanner;
double bodyTemp;
bodyTemp = scanner.nextDouble () ;
Code segment A
} // end of main
} // end of class
Salary paid per week: First 30 hours at a fixed rate of RM 20.00 per hour. The next following hours,
ovrtime rate at 1.5% of the fixed rate hourly.
Salary paid per week: Fixed salary of RM200.00 plus commision 10% of the total sales per week.
Write a complete Java program that prompts user to enter cook's hours worked per week, and
salesperson's total sales per week. Display the weekly salary for both cook and salesperson.
The process to calculate the amount of weekly salary for the cook uses the method calcSalaryCook
(int hour) which returns the weekly salary for the cook, and for the salesperson the process uses the
method calcSalarySalesPer (double sales) which returns the weekly salary for the salesperson.
PSPM 1 2020/2021
(d) Classify a suitable programming language paradigm based on the given description.
[3 marks]
Description Programming Language Paradigm
The program statements that express facts and
rules about problem within a formal logic system
The program consists of routines, subroutines or
functions to carry out a series of computational
steps.
A program that uses object that include both data
and function
PSPM 1 2018/2019
Compiler
4. Give one (1) difference between low-level programming language and high-level
programming language
PSPM 1 2011/2012
ii. ii.