You are on page 1of 2

UNIT SAINS KOMPUTER

KOLEJ MATRIKULASI MELAKA

TUTORIAL 3.0: JAVA LANGUAGE

Learning Outcome (CLO1)


3.1 (c) Construct Simple Programs

TUTORIAL QUESTIONS

1. Write a Java program that display “Java My World “.

2. Create a program that assign your name and display it.

3. Write a Java code that assign an integer value to a variable then display it.

4. Write a program that multiply two numbers, 7 and 8.

5. Create Java code that calculate and display the sum of two numbers, 3 and 5
respectively.

6. Write a program that calculate and display the average of three numbers; 3,7
and 5 respectively.

7. Write a program that calculate and display the average of three numbers entered
by user.

8. Create a Java code that prompt the user to enter two decimal values to num1
and num2 respectively and then add those two numbers.

9. Write a Java program that asks for the price of an item and the quantity
purchased and write the total cost.

10. Write a Java program that asks the user to enter two integers, obtained from the
user. Calculate and display the sum and product.
UNIT SAINS KOMPUTER
KOLEJ MATRIKULASI MELAKA

PSPM SC015 COLLECTIONS

SESSION 2019/2020
Learning Outcome (CLO1)
3.1 (c) Construct Simple Programs

1. Complete the following Java program to calculate and display the volume with
appropriate message.

class Cuboid {
public static void main (String[ ] args) {
double length = 4.5;
double width = 9.3;
double height = 7.8;
double volume;
}

2. Write a complete Java program to display the conversion result of 28.5 degree
Celsius to Fahrenheit using the following formula:
9
Fahrenheit: degree in Celsius X 5
+ 32

SESSION 2020/2021
Learning Outcome (CLO1)
3.1 (c) Construct Simple Programs

1. Assume p and q are integer variables. Swap the values of p and q.


Declare additional variables, if necessary.

You might also like