Professional Documents
Culture Documents
Lab Test Mohd Azmal Shahfari Bin Kamarul Zamal (21bt02014)
Lab Test Mohd Azmal Shahfari Bin Kamarul Zamal (21bt02014)
ID : 21BT02014
and display the net salary. Net salary is calculated by subtracting (15%) from
gross salary.
(10 marks)
1.
import java.util.Scanner;
//Variables
//Input
gross_salary=io.nextDouble();
//Process
netsalary=85*gross_salary/100;
//Output
1st hour costs RM2.00. The subsequent hours cost RM1.00 per hour. Calculate
(10 marks)
2.
import java.util.Scanner;
//Variables
//Input
entrytime=io.nextInt();
exittime=io.nextInt();
//Process
if (period<=1)
charge=2;
else
charge=2+(period-1);
//output
problem:
A program allows the user to enter any two integer’s values and another single digit called code.
Depending on what the user input for the code, do the following:
If the code is 5 or 6, display the division of first integer with the second integer.
Remember to check division by zero. Any other values of code, display the invalid message.
(20 marks)
3.
import java.util.Scanner;
float finalanswer;
integer1=io.nextInt();
integer2=io.nextInt();
code=io.nextInt();
finalanswer=integer1;
System.out.println(finalanswer);
finalanswer = integer1*integer2;
System.out.println(finalanswer);
}
if(integer2 == 0) {
System.out.println(
else {
finalanswer=integer1/integer2;
System.out.println(finalanswer);
} else {
System.out.println("Invalid code.");}