Need help with a "missing return statement"
Maybe I'm missing something, but the return is right there, plain as day...
This is the typical bank account program when learning about classes.
Code :
package lab03;
public class Account
{
public double balance;
public Account(double amount)
{
balance = amount;
}
public Account()
{
balance = 0.0;
}
public void deposit(double amount)
{
balance += amount;
}
//THIS IS WHERE I NEED HELP
public double withdraw(double amount)
{
if (balance >= amount)
{
//it says there's a missing return statement, but it's right here
return balance -= amount;
}
else
{
System.out.println("Insufficient funds");
}
}
public double getBalance()
{
return balance;
}
}
Re: Need help with a "missing return statement"
What happens if balance is less than amount?