-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathEmployeeWageComp.java
54 lines (45 loc) · 2.07 KB
/
EmployeeWageComp.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package employeeWageComp;
public class EmployeeWageComp {
// Declared global variables
public static final int ABSENT = 0;
public static final int IS_PRESENT = 1;
public static final int IS_HALF_PRESENT = 2;
public static final int WAGE_PER_HR = 20;
public static final int NUM_OF_WORKING_DAY = 20;
public static final int MAX_WORKING_HR = 100;
public static void main(String[] args) {
// Print Program Name
System.out.println("\nWelcome to Employee Wage Computation Program");
// Declared local variables
int DailyWage = 0;
int EmpHr = 0;
int TotalEmpWage = 0;
int TotalEmpHrs = 0;
int NoWorkingDay = 0;
while (TotalEmpHrs <= MAX_WORKING_HR && NoWorkingDay < NUM_OF_WORKING_DAY){
NoWorkingDay++;
double RANDOM = Math.floor(Math.random()*3);
// Employee Wage Calculation as per Present, Absent Or Half Time By using Switch
switch((int)RANDOM){
case 0:
System.out.println("Employee is Absent");
EmpHr = 0;
break;
case 1:
System.out.println("Employee is Present");
EmpHr = 8;
break;
case 2:
System.out.println("Employee is Half Time");
EmpHr = 4;
}
// Calculate Daily Employee Wage
DailyWage = WAGE_PER_HR * EmpHr;
TotalEmpWage += DailyWage;
TotalEmpHrs += EmpHr;
System.out.println("Employee Wage: " + DailyWage);
}
System.out.println("Total Employee Wage: " + TotalEmpWage);
System.out.println("Total Employee Working Days : " + TotalEmpHrs);
}
}