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

Kms PDF

This document contains a 6 question practice paper for a programming exam. Question 1 asks about object-oriented vs procedural programming and types of code translators. Question 2 involves calculating entrance fees for a zoo based on age, nationality, and family size. Question 3 provides a problem statement to write a pseudocode program to count students getting an A based on trial exam marks. Question 4 contains Java code segments and asks about output and rewriting code using for loops. Question 5 involves writing Java code to calculate a fuzzy coefficient and parking fees based on hours. Question 6 asks to write method definitions and calls to check number divisibility and write a program to find lowest sales amounts from region data in an array.
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)
84 views8 pages

Kms PDF

This document contains a 6 question practice paper for a programming exam. Question 1 asks about object-oriented vs procedural programming and types of code translators. Question 2 involves calculating entrance fees for a zoo based on age, nationality, and family size. Question 3 provides a problem statement to write a pseudocode program to count students getting an A based on trial exam marks. Question 4 contains Java code segments and asks about output and rewriting code using for loops. Question 5 involves writing Java code to calculate a fuzzy coefficient and parking fees based on hours. Question 6 asks to write method definitions and calls to check number divisibility and write a program to find lowest sales amounts from region data in an array.
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

Question Mark PrePSPM SC025

1
Kolej Matrikulasi Selangor
2 Sesi 22/23
3
4 Name: __________________________________

5 Matrix Number: ____________________


6
Tutorial: _________________________
Total

INSTRUCTION TO CANDIDATE:

This question paper consists of 6 questions.


Answer all questions in the space provided.
The use of non-programmable scientific calculator is permitted.

1. Programming Language is a computer language programmers use to develop software programs,


scripts, or other sets of instructions for computers to execute. Each programming language has their
own programming paradigm and translator used to convert the program into machine language.

a. Differentiate between Object-Oriented Programming and Procedural Programming.


[2 marks]
________________________________________________________________________________
________________________________________________________________________________

b. State the types of translator based on the following codes.


[3 marks]

Code Types of translator

int age [] = {8, 7, 9, 10, 45};


age [3] = 65;
System.out.println (age [0]);

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

ADULT RM45.00 RM50.00

CHILDREN RM18.00 RM25.00


(3 - 12 years old)

SENIOR CITIZEN RM23.00 RM50.00


(60 years and above)

Identify the input, process and output to calculate the entrance fee for one family.
[10 marks]

Input Process Output

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

i. Determine the value output.


[3 marks]

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.

Hours Parked Rate per Hour (RM)

Less than 3 hours 3

After 3 hours 2.50

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

You might also like