I cannot get my if then statements to work correctly and I cannot figure out why. any help would be greatl appreciated.
import java.text.DecimalFormat;
import java.util.Scanner;
public class Lab02
{
public static void main(String args[])
{
Scanner input = new Scanner(System.in);
System.out.print("Number of Exemptions: ");
double NE = input.nextDouble();
System.out.print("Gross Salary: ");
double GS = input.nextDouble();
System.out.print("Interest Income: ");
double II = input.nextDouble();
System.out.print("Capital Gains: ");
double CG = input.nextDouble();
System.out.print("Charitable Contributions: ");
double CC = input.nextDouble();
double TI = GS + II + CG;
System.out.printf("%nTotal Income: %12.2f%n", TI);
double AI = TI - (NE * 1500) - CC;
System.out.printf("Adjusted Income: %9.2f%n", AI);
double TT1;
double TT2;
double TT3;
double TT;
if ((AI > 10000 && AI <= 32000)){
//TT1 = ((15/100) * (32000 - 10000));}
//else if ((AI<= 32000)){
TT1 = ((15/100) * (AI - 10000));}
else TT1 = 0;
if ((AI > 32000 && AI <= 50000)){
//TT2 = ((23/100) * (50000 - 32000));}
//else if ((AI <= 50000)){
TT2 = ((23/100) * (AI - 32000));}
else TT2 = 0;
if ((AI > 50000)){
TT3 = ((28/100) * (AI - 50000));}
else TT3 = 0;
System.out.println(TT1);
System.out.println(TT2);
System.out.println(TT3);
TT = TT1 + TT2 + TT3;
System.out.printf("Total Tax: %14.2f%n", TT);
}
I do have some extra stuff in there that i was also working with to try and figure out my problem.
Aucun commentaire:
Enregistrer un commentaire