-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPersonalNew.java
More file actions
100 lines (97 loc) · 4.07 KB
/
PersonalNew.java
File metadata and controls
100 lines (97 loc) · 4.07 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
import java.util.Scanner;
public class PersonalNew {
public static int taxRate(int netMoney){
int rate;
if(netMoney >=0 && netMoney <= 150000){
rate = 0;
}
else if(netMoney >=150001 && netMoney <= 300000){
rate = 5;
}
else if(netMoney >=300001 && netMoney <= 500000){
rate = 10;
}
else if(netMoney >=500001 && netMoney <= 750000){
rate = 15;
}
else if(netMoney >=750001 && netMoney <= 1000000){
rate = 20;
}
else if(netMoney >=1000001 && netMoney <= 2000000){
rate = 25;
}
else if(netMoney >=2000001 && netMoney <= 5000000){
rate = 30;
}
else{
rate = 35;
}
return rate;
}
public static void display(int rate,int netMoney){
int nM = netMoney;
float sumTax = 0;
int[] taxMoney = {150000,150000,200000,200000,250000,250000,1000000,3000000};
String[] calTax = {"Cal Tax 150000 * 5% = 7500","Cal Tax 200000 * 10% = 20000"
,"Cal Tax 200000 * 15% = 37500","Cal Tax 250000 * 20% = 50000 "
,"Cal Tax 1000000 * 25% = 250000 ","Cal Tax 3000000 * 30% = 900000 "};
int[] taxStep = {7500,20000,37500,50000,250000,900000};
System.out.println("Tax is "+rate+"%");
if(rate != 0){
int round = (rate/5);
if(round > 1){
System.out.println("Step "+round);
}
System.out.print("Cal Tax ");
for(int i = 1;i<=(rate/5);i++){
// System.out.print(nM + " - " + taxMoney[i-1] + " = ");
System.out.printf("%d - %d = ",nM,taxMoney[i-1]);
nM-=taxMoney[i-1];
}
sumTax += (nM*(rate/100f));
System.out.println(nM + " * " +rate + "%" + " = " + ((int)sumTax));
for(int x = (rate/5)-2;x>=0;x--){
System.out.println("Step " + --round);
sumTax+=(float)taxStep[x];
// System.out.printf("Cal Tax %d * %d% = %d",taxMoney[x],(x+1)*5,taxStep[x]);
System.out.println(calTax[x]);
}
System.out.println("Your Tax = " + (int)sumTax + " BTH");
}
else{
System.out.println("Your Tax = Free Tax ");
}
}
public static void main(String[] args) {
int result;
Scanner sc_salay = new Scanner(System.in);
Scanner sc_cyear = new Scanner(System.in);
Scanner sc_taxd = new Scanner(System.in);
Scanner sc_incost = new Scanner(System.in);
Scanner sc_str = new Scanner(System.in);
System.out.print("Enter Salary : ");
int salay = sc_salay.nextInt();
System.out.print("Enter Year cost : ");
int costYear = sc_cyear.nextInt();
System.out.print("Enter Tax : ");
int taxDeuction = sc_taxd.nextInt();
System.out.print("You have other income? ");
String check = sc_str.next();
char income = check.charAt(0);
int salayYear = salay*12;
if(income == 'Y'){
System.out.print("Input other income : ");
int incomeCost = sc_incost.nextInt();
result = salayYear-costYear-taxDeuction+incomeCost;
// System.out.println("Income : (" + salay + "x12) - " + costYear + " - " + taxDeuction + " - " +incomeCost + " = " + (int)result );
System.out.printf("Income : (%d x 12) - %d - %d - %d = %d\n",salay,costYear,taxDeuction,incomeCost,result);
display(taxRate(result),result);
}
else if(income == 'N'){
result = (salayYear-costYear)-taxDeuction;
// System.out.println("Income : (" + salay + "x12) - " + costYear + " - " + taxDeuction + " = " + result );
System.out.printf("Income : (%d x 12) - %d - %d = %d\n",salay,costYear,taxDeuction,result);
display(taxRate(result),result);
}
}
}