-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathIncomeTaxCalculator.java
More file actions
45 lines (32 loc) · 1.07 KB
/
IncomeTaxCalculator.java
File metadata and controls
45 lines (32 loc) · 1.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
import java.util.Scanner;
public class IncomeTaxCalculator {
public static void main(String[] args){
/*Take annual salary as input and calculate tax:
Up to 2,50,000 → No tax
2,50,001 – 5,00,000 → 5%
5,00,001 – 10,00,000 → 20%
Above 10,00,000 → 30%
Print the tax amount. */
Scanner sc = new Scanner(System.in);
System.out.println("Enter the annual salary :");
double salary = sc.nextDouble();
double tax = 0;
if(salary < 0){
System.out.println("Invalid input!!");
}
else if(salary <= 250000){
tax = 0;
}
else if(salary <= 500000){
tax = salary * 0.05;
}
else if(salary <= 1000000){
tax = salary * 0.20;
}
else{
tax = salary * 0.30;
}
System.out.println("Tax amount $"+tax);
sc.close();
}
}