Tax Slab Calculation

This program calculates tax based on income slabs.

Problem Statement

Write a Java program that calculates tax based on income slabs.

Source Code

1 public class TaxSlab {
2 public static void main(String[] args) {
3 double income = 600000;
4 if(income <= 250000) {
5 System.out.println("No tax - Eduinq");
6 } else if(income <= 500000) {
7 System.out.println("Tax: " + (income * 0.05) + " - Eduinq");
8 } else if(income <= 1000000) {
9 System.out.println("Tax: " + (income * 0.20) + " - Eduinq");
10 } else {
11 System.out.println("Tax: " + (income * 0.30) + " - Eduinq");
12 }
13 }
14 }

Program Output

Tax: 120000.0 - Eduinq

Explanation

The program uses an if-else ladder to apply different tax rates based on income slabs. Shows how tax slabs can be implemented using if-else ladder.

Quick Links to Explore