hi, im making a static float method and i couldn't figure out the error i'm getting: invalid method declaration; return required
Is there anyone can help with this

static calcTaxes(float grossPay)
{
float netPay ;

if (grossPay <= 300)
netPay = (float) (grossPay - (grossPay * 0.15));

if (grossPay <= 450)
netPay = (float)(grossPay - (grossPay * 0.20));

else if (grossPay > 450)
netPay = (float)(grossPay - (grossPay * 0.25));

}

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by hello214

I think you want it to be this :

``````static float calcTaxes(float grossPay)
{
float netPay ;

if (grossPay <= 300)
netPay = (float) (grossPay - (grossPay * 0.15));

if (grossPay <= 450)
netPay = (float)(grossPay - (grossPay * 0.20));

else if (grossPay > 450)
netPay = (float)(grossPay - (grossPay * 0.25));

return netPay
}``````

You forgot to set the return type of the function as well as returning a value.

Edited by firstPerson: n/a

thanks a lot.....

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.