Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a java program that computes the income tax for an individual. The program

ID: 3796597 • Letter: W

Question

Write a java program that computes the income tax for an individual. The program should ask the user to enter the total taxable income of the year. The program then uses the tax bracket (as shown below) to calculate the tax amount:

10% on taxable income from $0 to $10,000, plus

15% on taxable income over $10,000 to $40,000, plus

25% on taxable income over $40,000 to $80,000 plus

28% on taxable income over $80,000 to $150,000, plus

33% on taxable income over $150,000 to $350,000, plus

35% on taxable income over $350,000 to $450,000, plus

39.60% on taxable income over $450,000

* The program should display the total tax due to the user.

* The program should show an error message if the user enters a negative number.

Technique used:

(a) Variable and constant declaration and initialization is done following the naming convention of Java programs. (Note: Constant must be used in this program).

(b) Getting user input is done. (You can use the text at the console or the dialog boxes)

(c) Arithmetic operators are used.

(d) Showing output is done. (You can use the text at the console or the dialog boxes) (

e) if-else or switch statements should be used to complete the program.

Explanation / Answer

import java.util.Scanner;

public class Tax {

   public static void main(String[] args) {
       // TODO Auto-generated method stub
       System.out.println("Enter total taxable income of the year");
       double income;
       Scanner sc=new Scanner(System.in);
       income=sc.nextDouble();//accept income
       double tax;//to store tax amount
      
       //rates for income tax slab
       final double r1 = 10;
       final double r2 = 15;
       final double r3 = 25;
       final double r4 = 28;
       final double r5 = 33;
       final double r6 = 35;
       final double r7 = 39.6;
      
       //calculate tax on income
       if(income>=0&&income<=10000)
       {
           tax=income*r1/100;
       }else if(income>10000&&income<=40000)
       {
           tax=income*r2/100;

       }else if(income>40000&&income<=80000)
       {
           tax=income*r3/100;

       }
       else if(income>80000&&income<=150000)
       {
           tax=income*r4/100;

       }else if(income>150000&&income<=350000)
       {
           tax=income*r5/100;

       }else if(income>350000&&income<=450000)
       {
           tax=income*r6/100;

       }
       else
       {
           tax=income*r7/100;
          
       }
       System.out.println("Tax over amount "+income+" is "+tax);


   }

}

========================================================

Output:

Enter total taxable income of the year
460000
Tax over amount 460000.0 is 182160.0

=======================================================

Let me know if you have any queries

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote