user2984143
user2984143

Reputation: 85

Cannot find symbol in a method in Java

I am getting an error when I try to calculate the fedtax. But it says that It can not find the symbol. I have tried different things, but I still get the same error. Any help would be appreciated.

public class calculatetax  {  
  public static void main( String[ ]  args)  {
     Scanner kb = new Scanner(System.in);
      int employeehr = 0;
      int ratehr = 0;
      String stateresidence = "";
      String maritalstatus = "";

      System.out.println( " Employee Hours pls " ) ;
      employeehr = kb.nextInt();

      System.out.println( " Hourly Rate " ) ;
      ratehr = kb.nextInt();

      System.out.println( " State of residence" ) ;
      stateresidence = kb.nextLine();

      System.out.println( "Marital Status" ) ;
      maritalstatus = kb.nextLine();

     int wages = calculatewages(employeehr,ratehr);
     calculatefedax(wages,maritalstatus); 
  }

  public static int calculatewages( int n1, int n2 ) {  
     int wages = n1 * n2;
     System.out.println("Return Wages" + wages);
     return wages;
  }    


  public static double calculatefedtax(double fedtax, str maritalstatus) {     
    if(maritalstatus.equals("marry"))
    {
    fedtax = fedtax * .20;
    }
    else if (maritalstatus.equals("single"))
    {
    fedtax = fedtax * .25;
    }
    else
    {
    fedtax = fedtax * .22;
    }
     return fedtax;

  }       
}

Upvotes: 0

Views: 101

Answers (2)

cubecubed
cubecubed

Reputation: 238

You wrote str instead of String. You also forgot to import scanner. Lastly you figure out the fedtax but did nothing with it.

calculatefedax(wages,maritalstatus);

That should be something like

String fedtax = calculatefedax(wages,maritalstatus);

Fixed code

    import java.util.Scanner;

public class calculatetax {
    public static void main(String[] args) {

        Scanner kb = new Scanner(System.in);
        int employeehr = 0;
        int ratehr = 0;
        String stateresidence = "";
        String maritalstatus = "";

        System.out.println(" Employee Hours pls ");
        employeehr = kb.nextInt();

        System.out.println(" Hourly Rate ");
        ratehr = kb.nextInt();

        System.out.println(" State of residence");
        stateresidence = kb.nextLine();

        System.out.println("Marital Status");
        maritalstatus = kb.nextLine();

        int wages = calculatewages(employeehr, ratehr);
        double fedtax = calculatefedtax(wages, maritalstatus);
        System.out.println("Fedtax:" + fedtax);
    }

    public static int calculatewages(int n1, int n2) {

        int wages = n1 * n2;
        System.out.println("Return Wages" + wages);
        return wages;
    }

    public static double calculatefedtax(double fedtax, String maritalstatus) {

        if (maritalstatus.equals("marry")) {
            fedtax = fedtax * .20;
        } else if (maritalstatus.equals("single")) {
            fedtax = fedtax * .25;
        } else {
            fedtax = fedtax * .22;
        }
        return fedtax;

    }

}

EDIT: As Jeroen Vannevel pointed out and I totally missed you forgot the t when you did

calculatefedax(wages,maritalstatus);

Upvotes: 0

Jeroen Vannevel
Jeroen Vannevel

Reputation: 44438

int wages
String maritalstatus
calculatefedax(wages,maritalstatus)

calculatefedtax(double fedtax, str maritalstatus)

Do you see the problem?

You have no suitable method for int + String arguments. And str should be String.
Oh, and you appearantly have a typo in the method name. That's why it's telling you it can't find the symbol on that line.

Upvotes: 1

Related Questions