-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmypayrolls.java
More file actions
63 lines (51 loc) · 1.46 KB
/
mypayrolls.java
File metadata and controls
63 lines (51 loc) · 1.46 KB
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
55
56
57
58
59
60
61
62
63
import java.util.Scanner;
String name = "";
double payRate = 9.75;
double hoursWorked = 0;
double federalTax = 0.20;
double stateTax = 0.09;
double grossPay = 0;
double netPay = 0;
void setEmployee() {
Scanner input = new Scanner(System.in);
name = input.nextLine();
hoursWorked = input.nextDouble();
}
void hourlyPay() {
if (hoursWorked < 0) {
System.out.println(" something went wrong");
} else {
double amount = hoursWorked * payRate;
System.out.println("Pay is: $" + amount);
}
}
void federalDeduction() {
double tax = grossPay * federalTax;
System.out.println("Federal tax deduction: $" + tax);
}
void stateDeduction() {
double tax = grossPay * stateTax;
System.out.println("State tax deduction: $" + tax);
}
void calculatePay() {
grossPay = hoursWorked * payRate;
System.out.println("Gross pay is: $" + grossPay);
}
void calculateNetPay() {
federalDeduction();
stateDeduction();
netPay = grossPay - (federalTax + stateTax);
System.out.println("Net pay is: $" + netPay);
}
public static void main(String[] args)
Scanner input = new Scanner(System.in);
setEmployee();
calculatePay();
calculateNetPay();
System.out.println("Do you want to continue? (yes/no) ");
String choice = input.next();
if (!choice.equals("yes")) {
System.out.println("Ok bye!");
break;
}
}