YO,
I would be EXTREMELY grateful if someone can help me out with some boolean method stuff. I have this assignment where we've been building up this bank account project thing, and at the moment I've been asked to put in a boolean method called inBalance that returns true if the balance is in credit. I thought I had this down but I'm getting an error saying 'missing return statement'. I also need to put something in called canWithdraw that prevents money being drawn if there's enough in the balance, and with that one I don't even know where to begin. I hope it's not going to be too daunting if I paste the whole thing since as a total beginner it'd prolly be best to see everything that's there since I hardly understand what's going on haha. ANY advice would be so greatly appreciated.
package bankaccountex;
import java.util.Date;
public class BankAccount {
private double balance;
private double interestRate; // interest Rate for the account
private int accountNumber;
private double transFee = .1;
private int transNumber;
Date transDate;
//first constructor
public BankAccount(int number) {
balance = 0;
interestRate = 0.06; // all the accounts have an 6% interest Rate
accountNumber = number;
transNumber = 0;
}
//second constructor
public BankAccount(int number, double initialBalance) {
balance = initialBalance;
interestRate = 0.06; // all the accounts have an 6% interest Rate
accountNumber = number;
transNumber = 0;
//methods
}
public double getBalance() {
return balance;
}
public int showAccountNumber() {
return accountNumber;
}
public int showTransNumber() {
return transNumber;
}
public void deposit (double amount) {
balance = balance + amount;
transNumber = transNumber + 1;
transDate = new Date();
}
public void withdraw (double amount) {
balance = balance - amount;
transNumber = transNumber + 1;
transDate = new Date();
}
public void deductMonthlyCharge () {
if (transNumber > 10) balance = balance - (transNumber - 10) * transFee;
transNumber = 0;
}
public double calculateInterest(){
return balance * interestRate;
}
public boolean inBalance() {
if (balance > 0) {
return true;
}
}
public boolean canWithdraw(double amount) {
if (balance > ???) {
return true;
}
}
}