-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAssignment2.java
More file actions
29 lines (25 loc) · 837 Bytes
/
Copy pathAssignment2.java
File metadata and controls
29 lines (25 loc) · 837 Bytes
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
public class Assignment2 {
public static void calculatePay(double basePay, int hoursWorked) {
if (basePay < 8.0) {
System.out.println("Error: Base pay is below minimum wage.");
return;
}
if (hoursWorked > 60) {
System.out.println("Error: Hours worked exceeds maximum limit.");
return;
}
double totalPay;
if (hoursWorked <= 40) {
totalPay = basePay * hoursWorked;
} else {
int overtime = hoursWorked - 40;
totalPay = (basePay * 40) + (overtime * basePay * 1.5);
}
System.out.println("Total pay : " + totalPay);
}
public static void main(String[] args) {
calculatePay(7.50, 35);
calculatePay(8.20, 47);
calculatePay(10.00, 73);
}
}