the method in type not applicable for the arguments

后端 未结 4 1880
挽巷
挽巷 2020-12-20 10:53

I am getting this error message:

2 errors found:

Error: The method determineTaxRate(double) in the type PayCalculator is not applicable for

相关标签:
4条回答
  • 2020-12-20 11:03

    You haven't specified arguments for the methods which you are calling from printData() method, for example:

    System.out.println("Net Pay: " + calculateNetPay());
    

    You are calling calculateNetPay() with 0 arguments, where as in your method defnition you have specified, it needs 2 double arguments.

    public double calculateNetPay(double grossPay, double tax) { ... }
    

    Same applies for other errors you are getting.

    0 讨论(0)
  • 2020-12-20 11:05

    you have declared your method like this :

    public double determineTaxRate(double grossPay)
    

    and later invoke it like this :

    determineTaxRate()
    

    obviously,you have missed a parameter when invoking the method

    fix this by determineTaxRate(someDoubleVar)

    0 讨论(0)
  • 2020-12-20 11:16

    your method defined with one argument.But you are not passing any parameters.

    For calculateNetPay() also you are doing the same thing.

    0 讨论(0)
  • 2020-12-20 11:22

    You are calling

    determineTaxRate()
    

    But your method is defined as this:

    public double determineTaxRate(double grossPay)
    {
    

    Same with your other error. You need to pass a double to the method. Such as this:

    determineTaxRate(calculateGrossPay())
    
    0 讨论(0)
提交回复
热议问题