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));


}

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.

thanks a lot.....

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.