-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExample.java
More file actions
123 lines (110 loc) · 4.82 KB
/
Example.java
File metadata and controls
123 lines (110 loc) · 4.82 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
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
import java.util.*;
class Example{
public static void main(String [] args){
Scanner input = new Scanner(System.in);
System.out.println("------------------------------------------------------------------------");
System.out.println("| SALARY INFORMATION SYSTEM |");
System.out.println("------------------------------------------------------------------------");
System.out.println();
System.out.println();
int calTax = 1;
int calBonus = 2;
int calLoan = 3;
System.out.printf("%10s%d%s %s %n","[",calTax,"]","Calculate Income Tax");
System.out.printf("%10s%d%s %s %n","[",calBonus,"]","Calculate Annual Bonus");
System.out.printf("%10s%d%s %s %n","[",calLoan,"]","Calculate Loan amount");
System.out.print("Enter an option to continue >");
int option = input.nextInt();
switch(option){
case 1:
System.out.println("------------------------------------------------------------------------");
System.out.printf("| %40s | %n","Calculate Income Tax");
System.out.println("------------------------------------------------------------------------");
System.out.println();
System.out.print("Input Employee name -");
String name = input.next();
System.out.print("Input Employee salary -");
double salary = input.nextDouble();
System.out.println();
double taxAmount = 41667;
if(100000>=salary){
taxAmount =taxAmount*0;
System.out.println("You have to pay Income Tax per month: "+taxAmount);
}else if(100001<=salary & salary<=141667){
taxAmount =Math.round(taxAmount*0.06-(141667-salary)*0.06);
System.out.println("You have to pay Income Tax per month: "+taxAmount);
}else if(141667<=salary & salary<=183333){
taxAmount =Math.round(taxAmount*0.18-(183333-salary)*0.12);
System.out.println("You have to pay Income Tax per month: "+taxAmount);
}else if(183333<=salary & salary<=225000){
taxAmount =Math.round(taxAmount*0.36-(225000-salary)*0.18);
System.out.println("You have to pay Income Tax per month: "+taxAmount);
}else if(225000<=salary & salary<=266667){
taxAmount =Math.round(taxAmount*0.6-(266667-salary)*0.24);
System.out.println("You have to pay Income Tax per month: "+taxAmount);
}else if(266667<=salary & salary<=308333){
taxAmount =Math.round(taxAmount*0.9-(308333-salary)*0.3);
System.out.println("You have to pay Income Tax per month: "+taxAmount);
}else{
//375000 is fixed
taxAmount =Math.round((salary-308333)*0.36+37500);
System.out.println("You have to pay Income Tax per month: "+taxAmount);
}
break;
case 2:
System.out.println("------------------------------------------------------------------------");
System.out.println("| Calculate Annual Bonus |");
System.out.println("------------------------------------------------------------------------");
System.out.println();
System.out.print("Input Employee name -");
String name2 = input.next();
System.out.print("Input Employee salary -");
double salary2 = input.nextDouble();
System.out.println();
double bonus;
if(100000>salary2){
bonus = 5000;
System.out.println("Annual bonus "+bonus);
}else if(100000<=salary2 & salary2<=199999){
bonus = salary2*0.1;
System.out.println("Annual bonus "+bonus);
}else if(200000<=salary2 & salary2<=299999){
bonus = salary2*0.15;
System.out.println("Annual bonus "+bonus);
}else if(300000<=salary2 & salary2<=399999){
bonus = salary2*0.2;
System.out.println("Annual bonus "+bonus);
}else{
bonus = salary2*0.35;
System.out.println("Annual bonus "+bonus);
}
break;
case 3:
System.out.println("------------------------------------------------------------------------");
System.out.println("| Calculate Loan amount |");
System.out.println("------------------------------------------------------------------------");
System.out.println();
System.out.print("Input Employee name -");
String name3 = input.next();
System.out.print("Input Employee salary -");
double salary3 = input.nextDouble();
if(salary3<50000){
System.out.printf("%10s %n","You can not get a loan because your salary lessthan Rs.50 000...");
}else{
System.out.print("Input number of year :");
double years = input.nextDouble();
if(years>5){
System.out.printf("%10s %n","The maximum number of years of the year is 5");
}else{
double n = years*12;
double r = 0.15;
double monthlyInstallment = salary3*0.6;
double x = Math.pow(1+(r/12), n);
double loanAmount = Math.round (monthlyInstallment*(1-(1 /x))/(r/12));
System.out.println();
System.out.printf("You can get Loan Amount : "+loanAmount);
}
}
}
}
}