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

Link: https://www.doughroller.net/taxes/federal-income-tax-brackets-deductions-a

ID: 3754738 • Letter: L

Question

Link: https://www.doughroller.net/taxes/federal-income-tax-brackets-deductions-and-exemption-limits/

Code already provided:
/* Programmer: Date: Project: Lab 2.4 Tax File Name: Tax.java Program Description: Determines the taxes a person owes */
import java.util.*;
public class Tax{ public static void main(String[] args){ // Variable to accept the user's input Scanner keyboard = new Scanner(System.in);
// Enter your code here
} } /* Programmer: Date: Project: Lab 2.4 Tax File Name: Tax.java Program Description: Determines the taxes a person owes */
import java.util.*;
public class Tax{ public static void main(String[] args){ // Variable to accept the user's input Scanner keyboard = new Scanner(System.in);
// Enter your code here
} } Lab 2.4 Tax The 2018 tax tables and deductions are available here: mits Write a program that asks the user how they are filing their taxes (married joint, head of household, single, or married separate) and their annual income and then tells them how much they will owe in taxes (ignore any itemized deductions). Use the nextLine method of the Scanner class to determine how they are filing their taxes since it can be more than word. Make sure you do this before asking for their income. Complete the following steps to calculate how much the user will pay in taxes. 1. Ask them for their filing status. (String) 2. Ask them for their income. (double) 3. Subtract their standard deduction from their income. This can be found on the website listed above 4. Calculate the taxable income by subtracting their standard deduction from their income 5. Use their filing status and taxable income to determine how much they owe in taxes. 6. Tell the user how much they owe in taxes. Below are example outputs for your program. What is your filing status? Married joint What is your income? 100000 You owe $8739.0 in taxes. What is your filing status? Head of household is your income? 100500 You owe $12698.0 in taxes. What is your filing status? single What is your income? 40000 You owe $3169.59 in taxes. What is your filing status? Married What is You owe $21409.50 in taxes. separate your income? 125000

Explanation / Answer

Please give a Thumps Up if you like the answer

Program

import java.util.Scanner;

public class Computetax {
public static void main(String[] args) {
  // Create a Scanner
  Scanner keyboard = new Scanner(System.in);
  
  // Prompt the user to enter filing status
  System.out.print("What is your filing status? ");
  String status = keyboard.nextLine();
  
  // Prompt the user to enter taxable income
  System.out.print("What is your income? ");
  double income = keyboard.nextDouble();
  
  // Compute tax
  double tax = 0;
  
  // Compute tax for single filers
  if (status.equals("single"))
                {
   if (income <= 9525)
    tax = income * 0.10;
   
   else if (income <= 38700)
    tax = 952.50 + (income - 9525) * 0.12;
   
   else if (income <= 82500)
    tax = 4453.50+(income - 38700) * 0.22;
   
   else if (income <= 157500)
    tax = 14089.5 + (income- 82500) * 0.24;
   
   else if (income <= 200000)
    tax = 32089.5+(income - 157500) * 0.32;
   else if (income <= 500000)
    tax = 45689.5+(income - 200000) * 0.35;
                        else
    tax = 150689.5+(income - 200000) * 0.37;
  }
  
  // Compute tax for married filing jointly
                else if (status.equals("Married joint")) {
   if (income <= 19050)
    tax = income * 0.10;
   
   else if (income <= 77400)
    tax = 1905 + (income - 19050) * 0.12;
   
   else if (income <= 165000)
    tax = 8907+(income - 77400) * 0.22;
   
   else if (income <= 315000)
    tax = 28179 + (income- 165000) * 0.24;
   
   else if (income <= 400000)
    tax = 64179+(income - 315000) * 0.32;
   else if (income <= 600000)
    tax = 91379+(income - 400000) * 0.35;
                        else
    tax = 161379+(income - 600000) * 0.37;
  }
  
  
  // Compute tax for Head of Household
                else if (status .equals("Head of household")) {
   if (income <= 13600)
    tax = income * 0.10;
   
   else if (income <= 51800)
    tax = 1360 + (income - 13600) * 0.12;
   
   else if (income <= 82500)
    tax = 5944+(income - 51800) * 0.22;
   
   else if (income <= 157500)
    tax = 12698 + (income- 82500) * 0.24;
   
   else if (income <= 200000)
    tax = 30698+(income - 157500) * 0.32;
   else if (income <= 500000)
    tax = 44298+(income - 200000) * 0.35;
                        else
    tax = 149298+(income - 200000) * 0.37;
  }
                // Compute tax for Married filing separately
                else if (status.equals("Married separate")) {
   if (income <= 9525)
    tax = income * 0.10;
   
   else if (income <= 38700)
    tax = 952.50 + (income - 9525) * 0.12;
   
   else if (income <= 82500)
    tax = 4453.50+(income - 38700) * 0.22;
   
   else if (income <= 157500)
    tax = 14089.5 + (income- 82500) * 0.24;
   
   else if (income <= 200000)
    tax = 32089.5+(income - 157500) * 0.32;
   else if (income <= 300000)
    tax = 45689.5+(income - 200000) * 0.35;
                        else
    tax = 80689.5+(income - 300000) * 0.37;
  }
  else
                {
   System.out.println("Error: invalid status");
   System.exit(0);
  }
  
  
  
  // Display the result
  System.out.println("You owe $" + (int)(tax * 100) / 100.0+" in taxes");
}
}

Output

What is your filing status? Married separate
What is your income? 10000
You owe $1009.5 in taxes

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