0% found this document useful (0 votes)
64 views3 pages

PraUPS1 SC

The document describes an instruction sheet for a problem solving exam question. It includes questions about (1) algorithms, control structures, and representing algorithms with pseudocode and flowcharts, and (2) characteristics of object-oriented programming in Java including classes, objects, and code examples of input/output statements. The document provides explanations and code examples as responses to sub-questions under the main exam questions.
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)
64 views3 pages

PraUPS1 SC

The document describes an instruction sheet for a problem solving exam question. It includes questions about (1) algorithms, control structures, and representing algorithms with pseudocode and flowcharts, and (2) characteristics of object-oriented programming in Java including classes, objects, and code examples of input/output statements. The document provides explanations and code examples as responses to sub-questions under the main exam questions.
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/ 3

SC025 | Pra UPS1

Name: Class:

Instruction: Answer all questions.

1 The second step in problem solving is design a solution which involve developing the
algorithm.

(a) Describe algorithm.


[2 marks]
is sequence of well-defined procedure that allows a computer to solve problem

(b) There are two (2) techniques to represent algorithm.


Name the techniques.
[2 marks]
pseudocodes and flowchart

(c) Differentiate the techniques that you have mentioned in 1(b).


[2 marks]
Techniques Description
pseudocode is semiformal, English-like languange with a limited
(i) vocabulary that can be used to design an algorithms

flowchart is a graphical representation of an algorithm consisting of


(ii) geomatrical shapes that a connected to flow

(d) An algorithm can be described using only three (3) control structures. A control
structure is a block of programming that analyses variables and chooses a
direction in which to go based on given parameters. It shows the logical order of
program instructions.
Explain each control structure.
[6 marks]
Control Structures Explanation
sequence is a series of actions that are sequentially exucuted in the
(i) order they are written in an algoritm

selection is defines two courses of action depending on the


(ii) outcom of acondition

repetition is specifies a block of one or more statements that are


(iii) repetedly executed until a condition is satisfied

1
SC025 | Pra UPS1

2 Java is an object-oriented programming (OOP) language.


(a) There are four (4) characteristics of OOP.
Describe the characteristics.
[8 marks]
Characteristics
Description
of OOP

(i) abstaction

(ii) encapsulation

(iii) inheritance

(iv) polymorphism

(b) Classes and objects are two main components in OOP.


Define the following terms:
(i) Class
[1 mark]
is codes that define the behaviour of a java programming element called an object

(ii) Object
[1 mark]
is an entity

(c) In Java, input statement is a Java code that is used to accept data entered by user
into the computer using keyboard, whilst output statement is a Java code that is
used to display output on the console/computer monitor.
Write a Java statements that will

(i) accept values 1.7 and 64.2, and store them in variables height and
weight respectively.
[2 marks]
double height = sc.nextDouble(); // declare data type Double to variable
double weight = sc.nextDouble(); height/weight and assign value 1.7 t

(ii) display the message “Mark is: ” followed by value 97.5 stored in
variable mark.
[1 mark]
Double mark=97.5;
System.out.println("Mark is: "+ mark);

2
SC025 | Pra UPS1

(iii) accept value true or false and store it in variable answer.


[1 mark]
answer=sc.nextBoolean();

(d) Consider the Java program in Figure 1.

_________________________________________
_________________________________________

public class Rectangle {


public static void main (String[] args) {
double length = 4.0;
double width = 5.0;
double area;

_______________________________ ;

}
}

Figure 1

Complete the Java program above with:

(i) comments to inform the author of the program and the purpose of the
program.
[2 marks]
//Author : Puteri
/*Purpose of program is to find are of a rectangle

(ii) a Java statement to produce an output as follows:

The area of rectangle is 20.0

[1 mark]
System.out.print("The are of rectangle is"+ area);

END OF QUESTION PAPER


KERTAS SOALAN TAMAT

You might also like