In the previous article, we have seen Java Program to Calculate Salary of Employee
In this article we are going to see how to find the amount of tax to be deducted from the salary of an employee using java programming language. Before going into the topic what is income tax java program, tax calculation program in java, java program to calculate income tax, Income tax program in java, Tax calculation formula in java programming, Income Tax Calculator Java Code, you have to known previously for quick understanding, at least basics may helps to study this article interestingly.
Java Program to Find the Amount of Tax to be Deducted From the Salary of an Employee
Every working professional after crossing a certain salary threshold has to pay some amount of his/her income to the Government in form of “Income Tax”.
The amount of tax to be paid is depends on how much he/she earns. The more the income, the more tax you will pay.
For example, let’s consider the following
- Salary <= 10000: Tax=0%
- Salary: 10000 – 15000: Tax=4%
- Salary: 15000 – 20000: Tax=6%
- Salary: 20000 – 25000: Tax=8%
- Salary: 25000 – 30000: Tax=10%
- Salary > 30000: Tax=12%
Let’s see different ways to find the amount of tax to be deducted from the salary of an employee.
Method- 1: Java Program to Find the Amount of Tax to be Deducted From the Salary of an Employee By using Static Input Value.
Approach:
- Initialize a variable salary = 27000;
- Use the if-else statements to find the tax to be deducted from the salary as shown below.
- Now to find the salary after deducting the tax, simply subtract the tax amount from the salary.
Program:
public class Main { public static void main(String[] args) { double salary = 20000; double tax = 0; double tax_amount = 0.0; if ((salary > 10000) && (salary < 15000)) { tax = 0.4 * salary; } else if ((salary >= 15000) && (salary < 20000)) { tax = 0.06; tax_amount = 0.06 * salary; } else if ((salary >= 20000) && (salary < 25000)) { tax = 0.8; tax_amount = 0.08 * salary; } else if ((salary >= 25000) && (salary < 30000)) { tax = 0.10; tax_amount = 0.10 * salary; } else if (salary >= 30000) { tax = 0.12; tax_amount = 0.12 * salary; } System.out.println("The tax to be deducted from the salary is: " + tax + "% and the amount is: " + tax_amount); System.out.println("Salary after tax deduction is: " + (salary - tax_amount)); } }
Output: The tax to be deducted from the salary is: 0.8% and the amount is: 1600.0 Salary after tax deduction is: 18400.0
Method-2: Java Program to Find the Amount of Tax to be Deducted From the Salary of an Employee By Using User Input
Approach:
- Create Scanner class object.
- Take user input for the salary.
- Use the if-else statements to find the tax to be deducted from the salary as shown below.
- Now to find the salary after deducting the tax, simply subtract the tax amount from the salary.
Program:
import java.util.Scanner; public class Main { public static void main(String[] args) { double salary; Scanner sc = new Scanner(System.in); System.out.print("Enter your salary: "); salary = sc.nextDouble(); double tax = 0; double tax_amount = 0.0; if ((salary > 10000) && (salary < 15000)) { tax = 0.4 * salary; } else if ((salary >= 15000) && (salary < 20000)) { tax = 0.06; tax_amount = 0.06 * salary; } else if ((salary >= 20000) && (salary < 25000)) { tax = 0.8; tax_amount = 0.08 * salary; } else if ((salary >= 25000) && (salary < 30000)) { tax = 0.10; tax_amount = 0.10 * salary; } else if (salary >= 30000) { tax = 0.12; tax_amount = 0.12 * salary; } System.out.println("The tax to be deducted from the salary is: " + tax + "% and the amount is: " + tax_amount); System.out.println("Salary after tax deduction is: " + (salary - tax_amount)); } }
Output: Enter your salary: 17000 The tax to be deducted from the salary is: 0.06% and the amount is: 1020.0 Salary after tax deduction is: 15980.0
Have you mastered basic programming topics of java and looking forward to mastering advanced topics in a java programming language? Go with these ultimate Advanced java programs examples with output & achieve your goal in improving java coding skills.
Practice these:
- Write A Program To Calculate Income Tax Of An Employee In Java
- How To Calculate Tax In Java Program
- How To Calculate Tax In Java
- Calculate Income Tax Java Program
- Calculate Tax In Java
- Calculate Income Tax In Java
- Tax Calculator Program In Java
- Java For Income Tax
Related Java Programs: