Kms PDF
Kms PDF
1
Kolej Matrikulasi Selangor
2 Sesi 22/23
3
4 Name: __________________________________
INSTRUCTION TO CANDIDATE:
00000000
00000001
00000010
00000100
S1 B FWD
...
FWD EQU *
...
BKWD EQU *
1
2. Zoo Negara is one of the must see places when you visit Kuala Lumpur. Given below is the entrance fee
to enter Zoo Negara.
Entrance Fee
AGE MALAYSIAN FOREIGNER
Identify the input, process and output to calculate the entrance fee for one family.
[10 marks]
3. Algorithms is a step by step instruction to transform input into output that can be represented using
pseudocode or flowchart.
Prepare a pseudocode for a given problem statement given.
There are numbers of SPM 2023 candidates in SMK Jugra. Teacher Norita, who is a head of Mathematics
and Science department, wants to make a prediction on how many students will get A’s in Modern
Mathematics for SPM. Predictions will be made based on their trial SPM. Help her to count how many
students get A based on marks in the trial SPM for Modern Mathematics. To get an A, students must
get at least 80 marks.
To stop the program, users must enter an invalid value of mark (valid value of mark is 0 to 100). Then,
your program should display the average marks and the highest mark.
[16 marks]
2
3
4.
a. Answer question i and ii based on the following Java segment. Assume all variables have been
declared.
i = 25;
while ( i != 50){
System.out.print (i + “\t”);
if (i % 7 == 0)
System.out.print (“/n”);
i+=5;
}
ii. Change the code segment using for loop without changing the output.
[4 marks]
4
b. Based on the flowchart given, write a program segment.
[5 marks]
s=0
sum
false
s Print
true
Print
sum = sum + Mark [s]
s=s+1
5.
a. The fuzzy coefficient A is calculated based on the following formula:
𝐴 (𝑥) = 𝑥 2 - 1 for 𝑥 < 4
5 - x2 for 𝑥 ≥ 4
Based on the above formula, write a Java loop segment to calculate the fuzzy coefficient A for x
between 3 to 8.
[6 marks]
5
b. Write a Java selection statement that will calculate the parking fees based on hours parked as
below.
Calculate and display parking fees that the user needs to pay.
[5 marks]
6
6.
a. Given the following Java program, write
Part A - a method definition that will return true or false. The method receives an integer
number and evaluates whether the number is divisible by 9 or not.
Part B - a method call from main () to print the result.
[6 marks]
import java.util.Scanner;
class Question6a
{
public static void main (String [] args)
{
Scanner a = new Scanner (System.in);
int num = a.nextInt();
//PART B
//PART A
7
b. Mr. Riz Oman Orhan, sales manager at Eishal Music Company needs your help to write a complete
Java program that allows him to enter the quarterly sales amount made in each of 10 regions and
stored in an array called QuarterSales. Then, the program will
i. find and display the lowest quarterly sales amount
ii. display the number of region(s) that have the lowest quarterly sales amount
[10 marks]
import java.util.Scanner;
class EishalMusicCompany
{
public static void main (String args [])
{
Scanner in = new Scanner (System.in); //create object in
}
}
END OF QUESTIONS
8