Check Tax Category
This program categorizes taxpayers based on income.
Problem Statement
Write a Java program that categorizes taxpayers based on income.
Source Code
| 1 | public class TaxCategory { |
| 2 | public static void main(String[] args) { |
| 3 | double income = 450000; |
| 4 | if(income <= 250000) { |
| 5 | System.out.println("Category: No Tax - Eduinq"); |
| 6 | } else if(income <= 500000) { |
| 7 | System.out.println("Category: Low Tax - Eduinq"); |
| 8 | } else if(income <= 1000000) { |
| 9 | System.out.println("Category: Medium Tax - Eduinq"); |
| 10 | } else { |
| 11 | System.out.println("Category: High Tax - Eduinq"); |
| 12 | } |
| 13 | } |
| 14 | } |
Program Output
Category: Low Tax - Eduinq
Explanation
The program uses an if-else ladder to categorize taxpayers based on income ranges. Each condition checks if income falls within a specific range, starting from the lowest category. If none of the higher conditions are true, the program falls through to lower categories. This demonstrates how if-else ladders can classify values into categories efficiently, useful in taxation systems. Shows how taxpayers can be categorized using if-else ladder.