Waiting for answer This question has not been answered yet. You can hire a professional tutor to get the answer.
Objectives After completing this lab , you should be able to :
/**
* description of class TaxForm here.
*
* @author (your name)
* @version (a version number or a date)
*/
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()
{
}
/**
* 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: " + taxableIncome );
System.out.println("Federal tax: " + tax);
System.out.println("Amount due: " + amountDue);
}
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){
tax = Math.round(TEN_PCT);
} else if (taxableIncome > 9325 && taxableIncome <= 37950){
tax = Math.round ( (taxableIncome - 9325) * FIFTEEN_PCT + 932.5);
} else if (taxableIncome > 37950.0 && taxableIncome <= 91900){
tax = Math.round ( (taxableIncome - 37950) * TWENTYFIVE_PCT + 5226.25);
} else if (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){
tax = Math.round(TEN_PCT);
}else if(taxableIncome > 18650 && taxableIncome <=75900){
tax = Math.round ( (taxableIncome-18650) * FIFTEEN_PCT + 1865);
}else if(taxableIncome > 75900){
tax = Math.round ( (taxableIncome - 75900) * TWENTYFIVE_PCT + 10452.50);
}else {
System.out.print("ERROR");
}
}
}
- Attachment 1
- Attachment 2
- Attachment 3
- Attachment 4
- Attachment 5
- Attachment 6