0
1.8kviews
computer (java programming)

Write a program to calculate and print the tax amount as per the following rules.
Enter the salary of an employee. a)If the salary is below 200000 then no tax. b)If the salary is more than 200000 and less than or equal to 300000 then tax amount will be 5% of salary. c)If the salary is more than 300000 and less than or equal to 500000 then tax amount will be 7% of salary. d) If the salary is more than 500000 then tax amount will be 10% of salary.

1 Answer
2
219views

Code :-

 import java.util.*;
    public class findSalary {
        public static void main(String[] args) {
            Scanner sc = new Scanner(System.in);
            System.out.print("Enter the salary: ");
            double salary = sc.nextInt();
            double tax=0.00;
            if(salary < 200000){
                tax = 0;
            }
            else if (salary > 200000 && salary <= 300000){
                tax = (0.05*salary);
            }
            else if (salary > 300000 && salary <= 500000){
                tax = (0.07*salary);
            }
            else if(salary > 500000){
                tax = (0.10*salary);
            }
            System.out.println("The tax amount is " + tax);
        }
    }
Please log in to add an answer.