Demo this program to the instructor or upload the .java file to Ecampus.

Write a program named bankefc.java that allows you to set up checking accounts and loan accounts.  It should contain 3 classes: Customer, CheckingAccount, LoanAccount.  The CheckingAccount and LoanAccount classes inherit from the Customer class.  Create an ArrayList of 5 Checking Account customers and an ArrayList of 5 Loan Account customers.

The program should be set up in a loop with the following menu options:
(1)  Bank Information (show BankBalance, Bank Transactions, Number Customers)
(2)  Print out all Checking and Savings Account Customer Information
(3)  Deposit Money (ask user for the Record# and Amount)
(4)  Withdraw Money (ask user for the Record# and Amount)
(5)  Make Loan (ask user for the Record# and Amount of Loan)
(6)  Make Payment (ask user for the Record# and Payment Amount)
Extra Credit: Have options to add and delete customers.  Format output for currency.


Bank of Eastfield logo

Customer Class

Variable Names Variable Description
protected String FName, LName Customer's first and last name.
protected String Email Customer's e-mail address.
protected int CustomerTransactions The total number of transactions (deposits and withdrawals) made by the customer.
protected static double BankBalance The bank's total balance (static).  You should change this variable when customers make deposits, withdrawals, take loans, and make loan payments.
protected static int BankTransactions The bank's total number of transactions (static).  Increment this variable every time a customer makes a deposit, withdrawal, takes a loan, or makes a loan payment.
protected static int NumberCustomers The total number of customers at the bank (static).
Methods Names Methods Description
GetFName(), SetFName()
GetLName(), SetLName()
GetEmail(), SetEmail()

GetCustomerTransactions()
GetBankBalance()
GetBankTransactions()
GetNumberCustomers()
Get and Set methods

 

CheckingAccount Class

Variable Names Variable Description
private double CheckingBalance The customer's checking account balance.
private boolean OverdraftHistory Set to true if the customer has ever overdrafted.
Methods Names Methods Description
CheckingAccount(String theLName, String theFName, String theEmail, double OpeningDeposit) The constructor should (1) initialize the name and email variables,  (2) set CheckingBalance to OpeningDeposit,  (3)  add the OpeningDeposit to the BankBalance,  (4) increment BankTransactions,  (5) increment NumberCustomers.
GetCheckingBalance()
GetOverdraftHistory()
Get methods
Deposit(Amount) Deposit money into the customer's account (include the amount as a parameter).  Remember to increment BankTransactions and add Amount to BankBalance.
Withdraw(Amount) Withdraw money from the customer's account (include the amount as a parameter).  If the customer overdrafts, you should charge a $25 fee and set the OverdraftHistory flag.  Remember to increment BankTransactions and subtract Amount from BankBalance.

 

LoanAccount Class

Variable Names Variable Description
private double LoanBalance The customer's remaining loan principle.
Methods Names Methods Description
LoanAccount(String theLName, String theFName, String theEmail, double OpeningLoan) The constructor should: (1) initialize the name and email,  (2) set LoanBalance to OpeningLoan * 0.25 for an interest premium,  (3) subtract the OpeningLoan from BankBalance,  (4) increment BankTransactions,  (5) increment NumberCustomers.
GetLoanBalance() Get method
MakeLoan(Amount) Add this amount and a 25% interest premium to the LoanBalance.  Remember to increment BankTransactions and subtract Amount from BankBalance.
MakePayment(Amount) Subtract this amount from the LoanBalance.  If LoanBalance gets to 0, output a message (e.g. "Customer X just payed off his/her loan!").  Remember to increment BankTransactions and add Amount to BankBalance.


Inheritance


The Customer class is the superclass.  The CheckingAccount and LoanAccount are the subclasses.  They inherit all the properties and methods of the Customer super class by using the extends keyword.  For example:


class CheckingAccount extends Customer
{

How to Declare an ArrayList of Objects


In your main program, declare two ArrayLists - one for CheckingAccount and one for LoanAccount.   You can use the data below to get started.

ArrayList<CheckingAccount> Check = new ArrayList<CheckingAccount>();
Check.add(new CheckingAccount("Kirk","David","dkirk@dcccd.edu",10000.0));
Check.add(new CheckingAccount("Kirk","James","tribbles@starfleet.gov",2500.0));
Check.add(new CheckingAccount("Scott","Hulu","hulu@aol.com",2500.0));

ArrayList<LoanAccount> Loan = new ArrayList<LoanAccount>();
Loan.add(new LoanAccount("Zeus","Moses","moses@gmail.com",5000));
Loan.add(new LoanAccount("Einstein","Amy","aeinstein@starfleet.gov",1000));
Loan.add(new LoanAccount("Galileo","Julius","aeinstein@starfleet.gov",500));

Printing all Accounts

To print all accounts you can use a for loop to step through each ArrayList element.  The following example prints outs the last name of each checking account:

for (int x=0; x<Check.size(); x++)
{
   System.out.println( Check.get(x).GetLName() + "\t" + Check.get(x).GetFName());
}


Retrieving (static) Bank Information


For the static variables, remember that you can use any of the array elements and either the Check class or Loan class - they all point to the same variable.  The following two lines give you the same answer:

System.out.println( Check.get(0).GetBankBalance() );
System.out.println( Loan.get(0).GetBankBalance() );

Example Output

//Option 1 to print bank information
====================================================
| Bank of Eastfield Information
|
| Total Bank Balance: 8500.0
| Total Bank Transactions: 6
| Total Bank Customers: 6
====================================================

//Option 2 to print customer information
====================================================
| Checking Account Customers
| Rec LName FName Balance
| ---------------------------------
| 0   Kirk David 10000.0
| 1   Kirk James 2500.0
| 2   Scott Hulu 2500.0
|
| Loan Account Customers
| Rec LName FName Loan Balance
| --------------------------------
| 0   Zeus Moses 5000.0
| 1   Einstein Amy 1000.0
| 2   Galileo Julius 500.0
====================================================

//Option 3 to deposit money
====================================================
Enter checking record number:
2
Amount to deposit:
1000
Scott Hulu now has $3500.0