public double takeMoneyOut( double amount )
{
double totalBalance;
totalBalance = balance + overdraftLimit;
if( CheckWithdrawal(amount) == false ) {
// error message
}
else
{
// return totalBalance
}
}
public boolean CheckWithdrawal(boolean checkWithdraw)
{
if(checkWithdraw > balance )
{
return true;
}
else
{
return false;
}
}
In the
takeMoneyOut method the argument "amount" is of type
double. The
if statement in this method is calling the
CheckWithdrawal method sending the value of the "amount" variable. So this method call is to a (n apparantly non-existent) method with this type signature:
boolean CheckWithdrawal(double value)
But the type signature of your
CheckWithdrawal method is this:
boolean CheckWithdrawal(boolean checkWithdraw)
So java cannot find a method with the type signature that your
takeMoneyOut method is calling, ie, java cannot find a
takeMoneyOut method that takes a (type)
double argument. This causes the first compile error:
error: CheckWithdrawal(boolean) in Account cannot be applied to (double)
if( CheckWithdrawal(amount) == false )
In the CheckWithdrawal method the argument "checkWithdraw" is (primitive type) boolean. In the
if statement the condition has a type mis-match:
// boolean double
if(checkWithdraw > balance )
which results in the second compile error
error: operator > cannot be applied to boolean,double
if(check > balance )
To compare these two variables they must be the same type. Java is very prissy/picky about variable types. This is to avoid confusion: so everyone is very clear about what types are being passed around/manipulated by the jvm (java virtual machine).
So how to fix this?
Change this
public boolean CheckWithdrawal(boolean checkWithdraw)
to this
public boolean CheckWithdrawal(double checkWithdraw)