Professional Documents
Culture Documents
TUTORIAL QUESTIONS
3. Write a Java code that assign an integer value to a variable then display it.
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
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