PraUPS1 SC
PraUPS1 SC
Name: Class:
1 The second step in problem solving is design a solution which involve developing the
algorithm.
(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
1
SC025 | Pra UPS1
(i) abstaction
(ii) encapsulation
(iii) inheritance
(iv) polymorphism
(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
_________________________________________
_________________________________________
_______________________________ ;
}
}
Figure 1
(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
[1 mark]
System.out.print("The are of rectangle is"+ area);