-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlowControl.java
More file actions
174 lines (121 loc) · 4.91 KB
/
FlowControl.java
File metadata and controls
174 lines (121 loc) · 4.91 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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
import java.util.Scanner;
class Flowcontrol{
public static void main(String args[]){
Scanner s=new Scanner(System.in);
System.out.println("----------------------------------------------");
System.out.println("| \t SALARY INFORMATION SYSTEM\t |");
System.out.println("----------------------------------------------");
System.out.println("\n\t[1] Calculate Income Tax \n\t[2] Calculate Annual Bonus \n\t[3] Calculate Loan Amount \n ");
System.out.print("Enter an option to Continue > ");
int option=s.nextInt();
int incomeTax;
if(option==1){
System.out.println("----------------------------------------------");
System.out.println("| \t Calculate Income Tax\t |");
System.out.println("----------------------------------------------");
System.out.print("Input Employee name: ");
String employeeName=s.nextLine();
s.nextLine();
System.out.print("Input Employee Salary: ");
int employeeSalary=s.nextInt();
double tax=0;
if(employeeSalary<=100000){
tax=0;
System.out.println("No tax Charged");
}
else if(employeeSalary<=141667){
tax=(employeeSalary-100000)*0.06;
System.out.println("You have to pay income tax per month: "+(int)tax);
}
else if(employeeSalary<=183333){
tax=2500+(employeeSalary-141666)*0.12;
System.out.println("You have to pay income tax per month: "+(int)tax);
}
else if(employeeSalary<=225000){
tax=2500+5000+(employeeSalary-183332)*0.18;
System.out.println("You have to pay income tax per month: "+(int)tax);
}
else if(employeeSalary<=266667){
tax=2500+5000+7500+(employeeSalary-224999)*0.24;
System.out.println("You have to pay income tax per month: "+(int)tax);
}
else if(employeeSalary<=308333){
tax=2500+5000+7500+5000+5000+(employeeSalary-266666)*0.3;
System.out.println("You have to pay income tax per month: "+(int)tax);
}
else if(employeeSalary>308333){
tax=37500+(employeeSalary-308332)*0.36;
System.out.println("You have to pay income tax per month: "+(int)tax);
}
else if(employeeSalary<308333){
tax=37500+(employeeSalary-308332)*0.36;
System.out.println("You have to pay income tax per month: "+(int)tax);
}
}
//Annual Bonus
if(option==2){
System.out.println("----------------------------------------------");
System.out.println("| \t CALCULATE ANNUAL BONUS\t |");
System.out.println("----------------------------------------------");
System.out.print("Enter Employee Name - ");
String employeeName=s.nextLine();
s.nextLine();
System.out.print("Enter Employee Salary - ");
double employeeSalary=s.nextDouble();
if(employeeSalary<100000){
System.out.println("Annual bonus - ");
System.out.println(5000);
}
else if(employeeSalary <199999){
System.out.print("Annual Bonus - ");
System.out.print(employeeSalary*=0.1);
}
else if(employeeSalary<299999){
System.out.print("Annual Bonus - ");
System.out.println(employeeSalary*=0.15);
}
else if(employeeSalary<399999){
System.out.print("Annual Bonus - ");
System.out.println(employeeSalary*=0.2);
}
else if (employeeSalary>400000){
System.out.print("Annual Bonus - ");
System.out.println(employeeSalary*=0.35);
}
}
//Loan Amount
if(option==3){
System.out.println("----------------------------------------------");
System.out.println("| \t CALCULATE LOAN AMOUNT \t |");
System.out.println("----------------------------------------------");
System.out.print("Enter employee Name - ");
String employeeName =s.nextLine();
s.nextLine();
System.out.print("Enter employee Salary - ");
int employeeSalary =s.nextInt();
double loanAmount;
double monthlyInstallment=employeeSalary*0.6;
double annualInterest;
annualInterest=0.15;
int years;
if(employeeSalary>50000 ){
System.out.print("Enter Number of Year: ");
years = s.nextInt();
double monthlyRate=annualInterest/12;
int numberOfMonths=years*12;
double MonthInPower=Math.pow(1+ monthlyRate,numberOfMonths);
double numerator=1-(1/MonthInPower);
double denominator=annualInterest/12;
loanAmount=monthlyInstallment*(numerator/denominator);
if(years>5){
System.out.println("Maximum year is 5");
}
System.out.print("You can get loan Amount");
System.out.print((int)(loanAmount/1000)*1000);
}
else{
System.out.println("You cannot get loan Amount because your salary is less than Rs. 50 000......");
}
}
}
}