I've been tasked with creating a small IRS makeshift tax calculator. The assignments objectives to be completed are:
Write a class that prompts the user for the following information:
Filing status: Single or Married (entered as 1 for Single and 2 for Married)
Taxable income
Calculates and prints:
Filing status
Taxable income
Federal tax
I'm supposed to have specific calculations for each of the parameters, which include 0 to 27050, 27050 to 65500, and so on, which are included in the code. the real problem I'm having is that I can't seem to get the numbers to actually show up.
my code is the following:
import java.util.Scanner;
public class P4_Icel_Murad_IRS
{
public static void main(String[] args){
Scanner in = new Scanner(System.in);
System.out.printf("Enter Marital Status: (Single = 1, Married = 2):");
int relation = in.nextInt();
System.out.printf("Enter taxable income:");
int tax = in.nextInt();
if (relation == 1){
String status = "Single";
if (tax <= 27050){
double tax2 = tax - 0.0;
double tax3 = (tax2 * 0.15);
System.out.printf(status,tax,tax3);
}else if (27050 < tax && tax >= 65550){
double tax2 = (tax - 27050.0)* 0.275;
double tax3 = 4057.5 + tax2;
}else if (65550 < tax && tax <= 136750){
double tax2 = (tax - 65550.0) * 0.305;
double tax3 = 14645.0 + tax2;
}else if (136750 < tax && tax <= 297350){
double tax2 = (tax - 136750.0 - tax) * 0.355;
double tax3 = 36361.00 + tax2;
}else if (297350 < tax && tax <= 1e100){
double tax2 = (tax - 297350) * 0.391;
double tax3 = 93374.0 + tax2;
}
}
if (relation == 2){
String status = "Married";
if (tax <= 27050){
double tax2 = tax - 0.0;
double tax3 = (tax2 * 0.15);
System.out.printf(status,tax,tax3);
}else if (27050 < tax && tax >= 65550){
double tax2 = (tax - 27050.0)* 0.275;
double tax3 = 4057.5 + tax2;
}else if (65550 < tax && tax <= 136750){
double tax2 = (tax - 65550.0) * 0.305;
double tax3 = 14645.0 + tax2;
}else if (136750 < tax && tax <= 297350){
double tax2 = (tax - 136750.0 - tax) * 0.355;
double tax3 = 36361.00 + tax2;
}else if (297350 < tax && tax <= 1e100){
double tax2 = (tax - 297350) * 0.391;
double tax3 = 93374.0 + tax2;
}
}
}
}
Aucun commentaire:
Enregistrer un commentaire