Question
JAVA I need help printing the results in number format and correctly attached are the instructions and my failed test results I am not getting
JAVA
I need help printing the results in number format and correctly attached are the instructions and my failed test results I am not getting the correct output. below screenshots are those of my incorrect results and my code is printed below as well. please help.
import java.util.Scanner; import java.text.NumberFormat; import java.util.Locale; public class TaxForm { private double wages; private double taxableInterest; private double unempolymentComp; private int exemption; private double fedIncomeTaxWithheld; private double deduction;
private double AGI; private double taxableIncome; private double fedTax; private double amountDue; private double singleTax; private double tax; private double refund;
private final double TEN_PCT = 0.10; private final double FIFTEEN_PCT = 0.15; private final double TWENTYFIVE_PCT= 0.25; private final double TWENTYEIGHT_PCT = 0.28;
public TaxForm() {
//instatiating variables
}
/** * Constructor for objects of class TaxForm */ public void estimateTaxes() { Scanner Sc1 = new Scanner(System.in); System.out.println("Your Information");
System.out.println("Wages, salaries and tips: "); wages = Sc1.nextDouble();
System.out.println("Taxable interest: "); taxableInterest = Sc1.nextDouble();
System.out.println("Unemployment compensation: "); unempolymentComp = Sc1.nextDouble();
System.out.println("Exemptions (0, 1 or 2): "); exemption = Sc1.nextInt();
System.out.println("Federal income tax withheld: "); fedIncomeTaxWithheld = Sc1.nextDouble();
calculateAGI(); calculateDeduction(); calculateAmountDue(); if(exemption == 0 || exemption ==1){ calculateTaxSingle(); }else if (exemption == 3){ calculateTaxJoint(); }else { System.out.print("ERROR: invalid exemption"); } System.out.println("Your Result"); System.out.println("AGI: " + AGI); System.out.println("Taxable income: "); System.out.println("Federal tax: "); System.out.println("Amount due: "); }
public void calculateAGI(){ AGI = wages + taxableInterest + unempolymentComp; }
public void calculateDeduction(){ switch (exemption){ case 0: deduction = 6350.0; break;
case 1: deduction = 10400.0; break;
case 2: deduction = 20800.0; break;
default: System.out.print("ERROR: exemption does not exist"); }
}
public void taxableIncome(){ double deductedAGI = AGI - deduction; if (deductedAGI > 0){ taxableIncome = deductedAGI; } else { System.out.print("ERROR: Taxable Income is negative"); } }
public void calculateTaxSingle(){ if(taxableIncome > 0 && taxableIncome 9325 && taxableIncome
} else if (taxableIncome > 37950.0 && taxableIncome 91900){ tax = Math.round ( ( taxableIncome - 91900) * TWENTYEIGHT_PCT + 18713.75); }else { System.out.print("ERROR"); } }
public void calculateAmountDue(){ if (tax > fedIncomeTaxWithheld){ amountDue = fedIncomeTaxWithheld - tax; refund = 0; }else { refund = fedIncomeTaxWithheld - tax; amountDue = 0; } }
public void calculateTaxJoint(){ if (taxableIncome > 0 && taxableIncome 18650 && taxableIncome 75900){ tax = Math.round ( (taxableIncome - 75900) * TWENTYFIVE_PCT + 10452.50); }else { System.out.print("ERROR"); } } }
Objectives After completing this lab, you should be able to: . write short problem solutions involving conditional statements use NunkerRexmat to display currency values Definitions .Wages-amount you earned and reported on a W-2 form . Taxable interest- the amount a bank paid you in interest . Unemployment Compensation government payments for unemployment insurance .Federal income tax withheld-the amount of tax your employer withheld from your .Exemptions-the number of people dependent on your income (0 if single and your parents claim you as a dependent, 1 if you are single, and 2 if you are married) . Deduction amount subtracted from your income before taxes are calculated. This is based on the exemptions (0 is S6,350, 1 is S10,400 and 2 is $20,800). .Adjusted gross income (AGI)-the total of wages, taxable interest and unemployment . Taxable income - AGI minus deductions (can not be below zero) .Tax-amount of tax is based on the taxable income and rates provided in the tax table depending on filing status (e.g. single or married filing jointly). Use Matbuauad) to round to the nearest whole number . Amount owed-if the tax is greater than the tax withheld .Refund - if the tax is less than the tax withheld Lab Activity #1-TaxEorm Implement a class called TaxERxn, that calculates the U.S. federal tax given specific information. Include proper documentation including method headers to create elegant code. public void estimate Taxes -write a method that prompts the taxpayer for certain information and then displays results including adjusted gross income, taxable income, federal tax and refund (or amount due). This simplified form is only for taxpayers who earned less than S100,000 and have no dependents. Read user input using a Scanner Use a Nuwberxmat object to display currency amounts (Locale.US) . Use finals for tax rates within the method. For example final double FIFTEEN PCT -0.15; Sample Output Your prompts should look similar to the following. Pay attention to blank spaces and new lines. Keyboard input shown in boldface for clarity in this document (but not on the screen) Sample #1 Your Information Mages, salaries and tips: $14000 Taxable interest: $23 Unemployment compensation: $0 Exemptions (, 1 or 2): 0 Federal income tax withheld: $660 Your Results AGI: $14,023.00 Taxable income: $7,673.00 Federal tax: $767.00 Amount due: S$107.00 Sample #2 Your Information Mages, salaries and tips: $18900 Taxable interest: $47 Unemployment compensation: $0 Exemptions (, 1 or 2): 2 Federal income tax withheld: $978 Your Results AGI: $18,947.00 Taxable income: S0.00 Federal tax: S0.00 Your refund: $978.00 Sample #3 Your Information Mages, salaries and tips: $99999 Taxable interest: S0 Unemployment compensation: $0 Exemptions (, 1 or 2): 1 Federal income tax withheld: $15000 Your Results AGI : $99,999.00 Taxable income: S89,599.00 Federal tax: $18,139.00 Amount due: 3,139.00 2017 Federal Tax Table: Filing Single If vour income is: Over SO 9.3 The tax is: of the amount over SO 9.3 37 950 S91 But not over 10% S91,900 S91 For example, to calculate the second row on the table: if (taxable >9325 taxable37950) tax -Mathixound (taxable 9325) FIFTEEN_ PCT 932.5) 2017 Federal Tax Table: Married Filing Jointl If vour income is: Over SO The tax is: But not over of the amount over SO 10% Recommended Sequence of Actions 1. 2. Calculate AGI 3. Ask and answer the five questions a. Compile, run and test Determine amount of deduction based on exemptions (use a switch statement) a. Compile, run and test 4. Calculate taxable income (adjust if negative) a. Compile, run and test 5. Calculate tax for singles (exemption of 0 or 1) Compile, run and test Calculate federal tax owed (or due) a. 6. 7. Print all results using NumberEormat 8. 9. Compile, run and test Go back and calculate tax for married Compile, run and test a. a. Everything working? Show your instructor a. b. Copy to zxLab for both partners- Chapter 6. 1: Student 0/4 Input 15000 0 3000 0 Your Information Wages, salaries and tips: Taxable interest: Unemployment compensation: Exemptions (0,1 or 2): Your output Federal income tax withheld: ERRORYOur Result AGI: 18000.0 Taxable income: 0.0 Federal tax: 0.0 Amount due: 0.0 Your output does not contain $1,281.00 3: Single 0/4 nput 30000 150 50 1 3000 Your Information Wages, salaries and tips Taxable interest: Unemployment compensation: Exemptions (0, 1 or 2) Your output Federal income tax withheld: ERRORYour Result AGI: 30200.0 Taxable income: 0.0 Federal tax: 0.0 Amount due: 0.0 Your output does not contain $496.00 2: Married ^ 0/4 Input 75000 0 0 2 9000 Your Information Wages, salaries and tips: Taxable interest: Unemployment compensation: Exemptions (0,1 or 2): Your output Federal income tax withheld: ERROR: invalid exemptionYour Result AGI: 75000.0 Taxable income: 0.0 Federal tax: 0.0 Amount due: 0.0 Your output does not $7,198.00Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started