Question 1-6

Recall the Account definition methods.

double getBalance()
Returns the amount of money held in the object account.

void deposit(double amt)
Adds amt dollars to the object account's balance.

void withdraw(double amt)
Subtracts amt dollars from the object account's balance.

Complete the following method that employs the above definition to find the total amount of money deposited in the bank.

public class BankFunctions {
    public static double totalAssets(Bank bank) {



    }
}

Solution

public class BankFunctions {
    public static double totalAssets(Bank bank) {
        double ret = 0.0;
        for(int i = 0; i < bank.getNumAccounts(); i++) {
            ret += bank.getAccount(i).getBalance();
        }
        return ret;
    }
}

Back to Review for Midterm 1