I am new programming with Java and I have found an error that I haven't been able to solve. I have revised all my code multiple times and I don't seem to find any mistake (It could be also that I'm not really experienced with the language :/ ). When trying to run my code, this is what the console shows me
"Exception in thread "main" java.lang.RuntimeException: Uncompilable source code - cannot find symbol symbol: variable TaxReturn location: class taxReturnTester .... "
I can see the error is because of my variable "TaxReturn" but besides changing an initial capitalization mistake, I don't see what else is wrong with it!!
This is my code:
package taxreturn;
public class TaxReturn {
public TaxReturn (double anIncome, int aStatus){
income=anIncome;
status = aStatus;
}
public double getTax (){
double tax = 0;
if (status == Single ){
if (income <= Single_Bracket1)
tax = Rate1 * income;
else if ( income <= Single_Bracket2)
tax = Rate1 * Single_Bracket1 + Rate2*(income - Single_Bracket1);
else
tax = Rate1 * Single_Bracket1 + Rate2 * (Single_Bracket2 -
Single_Bracket1) + Rate3 * (income - Single_Bracket2);
else
if (income<= Married_Bracket1)
tax=Rate1 * income;
else if (income <= Married_Bracket2)
tax= Rate1 * Married_Bracket1 + Rate2 * (income -
Married_Bracket1);
else
tax = Rate1 * Married_Bracket1 + Rate2 * ( Married_Bracket2 -
Married_Bracket1) + Rate3 * (income - Married_Bracket2);
}
return tax;
public static final int Single = 1;
public static final int Married = 2;
private static final double Rate1= 0.5;
private static final double Rate2= 0.25;
private static final double Rate3= 0.75;
private static final double Single_Bracket1= 21450;
private static final double Single_Bracket2= 51900;
private static final double Married_Bracket1= 35000;
private static final double Married_Bracket2= 86800;
private double income;
private int status;
import java.util.Scanner;
public class taxReturnTester {
public static void main (String [] args) {
Scanner in = new Scanner (System.in);
System.out.print("Please Enter your Income:");
double income = in.nextDouble();
System.out.print("Please enter S (single) M (Married): ");
String input = in.next();
// CHECK POINT
System.out.println("Check point1");
int status= 0;
if (input.equalsIgnoreCase("s"))
status= TaxReturn.single;
else if (input.equalsIgnoreCase("m"))
status = TaxReturn.married;
else
System.out.println("Wrong Input. Please do it again");
return;
}
}
TaxReturn aTaxReturn = new TaxReturn(income,status);
System.out.println ("The tax is" + aTaxReturn.getTax() );