The words you are searching are inside this book. To get more targeted content, please make full-text search by clicking here.
Discover the best professional documents and content resources in AnyFlip Document Base.
Search
Published by kamariah bahari, 2020-03-22 00:03:58

Microsoft Word - KMPK SchemePRAPSPM SET B_SC025-1819

S
P
C
A
M
P

S
2
PRAPSPM SC025
5
P
R
0
KMPK 2018/2019
Answer Scheme set B
t

e
e
w
A
B
s
n
c
e
he
m
S
r
s

























































































TO
TU
I
R




A
M
NAME : TUTORIAL:L:
N
:
A
E




















































LECTURER NAME :
D
R

D
T
N
E
I
C
A
TY

N
B
E
R
M
U
MATRIC NUMBER I IDENTITY CARD NUMBER
M S

SC025
Computer Science
Semester 2
2018/2019
2 ½ hours






TI

N
K
O
LL
O
C
U
PERAK MATRICULATION COLLEGE
P
A
E
I
TR
C
E
M
A
E
A
R
L
G

M
Y
S
I
A
L
A

A
O
M
T
MINISTRY OF EDUCATION MALAYSIAA
I
D
E
N
I
C
F
U
Y
O
N
R
T
I

S

TRIAL TEST
SET B (Answer Scheme)

COMPUTER SCIENCE
2 ½ HOURS


D
N
O
S
LE
O
O
K
O
H
S
O
O
B
T
T
A
N
E
DO NOT OPEN THIS BOOKLET UNTIL YOU ARE TOLD TO DO SOOO
R
U
O
E
L
P
Y
D
U
T
T
T
D D O N O T O P E N TH I I S B O O K LE T U N T I I L Y O U A R E T O LD TO D O S
N
O
L
TO
Q ue s t i on N u m b e r Mark
Question Number
SECTION A
1 /4
2 /7
3 /7
4 /7
5 /7
6 /11
SECTION B
1 /11
2 /15
3 /13
4 /13
5 /4
6 /11
Total Markk
T ot a l M a r / 110

Bil Answer Mark

PRAPSPM SC025
KMPK 2018/2019
Answer Scheme set B
1 2 techniques are
- flowchart and pseudocode. 2 marks

Pseudocode an artificial, informal language (similar to english) used to develop
algorithm. While flowchart a graphical representation of an algorithm in relation to 2 marks
its sequence of functions

2 a. Inheritance- mechanism in which one object acquires all the properties and 1 mark
behaviors of a parent object.
Encapsulation- process of wrapping code and data together into a single unit. 2 mark
Abstraction - process of hiding the implementation details and showing only
functionality to the user.
Polymorphism- Polymorphism is a concept by which we can perform a single
action in different ways

b 1 mark
i. Object is an entity that has both state and behaviour. Object also known as an
instance of a class.

ii. 3 marks
-State / Attribute
-Behaviour
-Identity


3 a. 4 marks
i. 6.0 atau 6 (bukan 6.5 sebab int /int hasil tetap integer)
ii. 17
iii. 13.25
iv. 1
b. x = 8 3 marks
y = 5
z = 8

4 a.Array is an ordered indexed collection of data values of the same type 2 marks

b. 2 marks
i integer (int), hold whole number 2 marks
ii. car_no[3] = 7423 and car_no[6]=2148
c.1978 1 mark

5. a. A programming technique that solve complex problem by divide it into smaller 2 marks
sets by creating objects.

b. 94 @ 100999794 2 marks
c. 4 marks
int birthyear = in.nextInt();
String name = in.nextLine(); OR in.next();
char gender = in.next().charAt(0);
//1 marks for each (3marks) and 1 mark for correct syntax.

6. import java.util.Scanner; 11 marks
class BaseExp {
public static void main(String[] args) {

PRAPSPM SC025
KMPK 2018/2019
Answer Scheme set B
Scanner sc = new Scanner(System.in);
BaseExp obj = new BaseExp(); //1mark

System.out.print("base: "); //prompt user enter base
int base = sc.nextInt(); //1mark

System.out.print("power: ");
int power = sc.nextInt(); //1 mark
System.out.print("Answer : " +obj.findExponent(base, power));
//2marks
}
public int findExponent(int x, int y) { //2 marks
int result=1; //1mark
for (int i = y; i > 0; i--) OR for (int i = 1; i <=y; i++)//1mark
result = result*x; //1mark
return result; //1mark
}
}

Section B


1 a. 3 marks
Input : number of tiles (1Mark) / qtyTiles
Process : to calculate number of boxes based on number of tiles (1 Mark)
Output : number of boxes(1 Mark)

b. Input : qtyDVD (1Mark) 4 marks
Process : Determine profit based on qtyDVD (2 Marks)
Output : profit (1 Mark)

c. -Writing comments between your lines of codes Or 1 mark
- creating a separate text file to explain the program.

d. 3 types of errors: (1 mark for any type, 1 mark explain , 1 mark example) 3 marks
- Syntax error - the error occur when the syntax of the programming
language is violated.Example missing semicolon in the process statement.
result = a+b
- Run-Time error - the error occur when a program with no syntax errors asks
the computer to do something that the computer is unable to reliably do.
Example : divide variable with 0.
- Logic Error -the error occur when there is a design flaw in your program or
the output is wrong.Example multiplying when you should be dividing.




2 a. 6 marks
Start
Read num
i =1
Repeat while i <=10 (i is less than or equal to 10)
ans = num x i

M

S
P
0
2
S
C
5
P
PRAPSPM SC025
P
A
R
KMPK 2018/2019
Answer Scheme set B
S

c
m
he
r
n
A
s
e
w
e
s


B
t
e
u
+


+

i
+

s

n
a




m
+




x
+

n

Display num + “ x” + i + “=” + ans + “\n”
=
i++
End repeat
End
b. Flowchart 6 marks

Start 3 marks
t


A
=

5




B

=

se
A


,
d
e
R
Read A, B @ set A=5 B= 100
a


@


1
B



Temp = A
A=B
B= Temp

Display A,B
End
3 1. // Good Luck for PSPM 2 marks
2. /* Good Luck for PSPM*/
b. 2 marks
if (count>100)
y
)

n
t
i
p
r
o
o
T
(

.
st
e
y
System.out.print(“Too Many”);;
S
u
t
o
m
.
n

a
M
c. 5 marks
i.(count < 5)
ii. sum=20, count = 6
iii. sum=0, count = 5
d. 4 marks
double x, y;
for( x = 5; x<=10; x=x+0.2)
{
x


;



+
w
(
p
o
2
)

x,

=
*
3
y=3*x*x+x; @ y=3*Math.pow(x,2)+x;;


y

+


x

x
x
*
.







@















a
M
*

h



t
3







=
y

System.out.print(y);
}

M

P
P
S
2
5
0
S
C
A
P
R
PRAPSPM SC025
KMPK 2018/2019
Answer Scheme set B

s
s

B
t
e
w
c
r
A

S
e
e
m
he
n
n
h
t
b
o
a
r

b
e
t

s
m
d
r
n
s


u
a
m
t
h
e
h
se

e
r
a
e
ii. Determine whether “the three numbers are the same” or not based on 2 marks
e
e
e
num1, num2, num3

e
n
b

e
r
r
e
h

s
e
e
e
e
iii. “The three numbers are the same”” or “ The………………..” 2 marks
h
a
m
h
u
r

t
t
sa

T
m
r
e
i
r
e
m
f
b
f
e
e

n
iv. “ “The three numbers are different”” 2 marks

n
u
t
d
a
T
t
e

r
e
e
s
r
h
h
v. Flowchart 6 marks



a
n
r
e

d
)
n
/
q
5. a. int findSquare(int x) // OR int findSquare (int x) 2 marks

n
q
u

a
d
S
O
i
u



R
i
t
t
n
S

(
i
i
f
t
n
(
i
x)
i
r
f
x



n
e
t
/
t

s(
d
t
o
s
e
e
=
d


h

J
)
e
o
w
;
n
M
b. JMethods obj = new JMethods(); 1 mark
J
b
o
h
M
j
c. obj.findSquare(i); 1 mark
6. import java.util.Scanner; 11 marks
class ConvertTemp {
a

vo
i
n
d
i
(
m

g
b
s
g


n
public static void main(String[] args) {{
)
a
a

i
r
c
st
[
]

l


t
r
i

S

c

i
p
u

t
m

n
S
ca
ca
i
.
w
n
S
)
n
i
(
n
n
S
Scanner in = new Scanner(System.in);;

e
=
n

n
r

e
r
st
e
e
y
C
;
m
(
t
)

n
T
r

o
ve
e
p
=
w
e
n
n
p
t
r
o

ve
C
j
ConvertTemp obj = new ConvertTemp(); //1mark
e
m
T

b
o
0
k

t
r
.
c

o
;
e
s

/
h
o

/
i
5
m
int choose; //0.5mark
a
n
s,
r
u
l
i
double celcius, fahrenheit; //1markk
b
ci
ce
h
a
r
t
e

m
f
e
1

h
e
a
/
;
d
o
n
u
l

/

(
p
C


E
e
o
o
u
d
t
System.out.print("Enter Code : (1)Convert C to F or (2) Convert F to
:
.
.

"
)
i
n
C
vert C to F or (2) Convert F to
e
e
(
t
y
n
t
n
S
t
o
s
m
r
1
r
C");
=
i
o
n
o

ch
)
n

;
s
xt
e
.
I

t
choose = in.nextInt(); //0.5mark
n
e
(

if (choose == 1) { //1mark
e
s
y
:
"
System.out.print("Celcius :" );;
S
)
s
t

o
r
n
e
c
i
.
l
(
.
p
t
C
u
t
"
m
u
i
e
c
ce
b

s
o
xt
n
=
.

u

(
i
u
e
n
;
celcius = in.nextDouble(); //0.5mark
l
)

i
l
D
"
)
System.out.print("Fahrenheit:" +obj.findFahrenheit(celcius));
:
f
)
e

(
o
;

t
b
.
p
e
+
.
"
j
r
t
c
Fa
e
d
h
i
l
.
t
i
e
Fa
c
r
h
s
(
r
u
i
n
t
i
n
n
u
i
m
n
e
h
e
o
h
//1mark
}
else {
r
n
System.out.print("Fahrenheit :");
p
i
.
e
h
s
a
o
i
n
e
e
m
h
t
r
t
t
)
"
;
t
.
(

F
y
u
S
"
:
n
e
.
n
D
r
xt
e
h
=
i
t

i
n

e
o
f
(
l
e
)


fahrenheit = in.nextDouble(); //0.5mark
;
u
a
b
h
o
y
s
t
S
m
.
System.out.print("Celcius : " +obj.findCelcius(fahrenheit));
e
c
i
l
C
e

"
:
u
s
p
r
.
u
t
(
"
t
i
n
//1mark

PRAPSPM SC025
KMPK 2018/2019
Answer Scheme set B
}
double findCelcius(double cel) { //1mark
double c;
c = 5*(cel-32) / 9.0; //0.5mark
return c; //0.5mark
}
double findFahrenheit(double fah) { //1mark
double f;
f = (9*fah / 5.0) + 32; //0.5mark
return f; //0.5mark
}
}


Click to View FlipBook Version