Advanced Programming
Assignment 5
1 Bank Account Application
You are an IT Support Administrator Specialist at BOA and are
charged with the task of creating new bank accounts for new bank
customers. Saving Account and Checking Account. Please complete
the following instructions:
2 Base class: public abstract class Account
_ List common properties for Saving and Checking accounts
{ private String name
{ private String sSN
{ private double balance
{ private static int index = 10000
//index will be incremented every time we create a new ac-
count
{ protected String accountNumber
{ protected double rate
{ constant number: BASE RATE = 2.5
_ Constructor to set base properties and initialize the account: name,
sSN, balance, accountNumber, rate
{ public Account(String name, String sSN, double initDeposit)
{ You also need to update index, set account number, set Rate
inside the Account constructor
_ Abstract method: public abstract void setRate();
_ List common methods for Saving and Checking accounts
{ Set account number: private String setAccountNumber()
_ generate a 12-digit account number: 4 digit of SSN + 5
digit uniqueID + 3 digit random number
_ 4 digit of SSN: the last four digit of SSN (sSN.substring(sSN.length()-
4,sSN.length()))
_ 5 digit uniqueID: index (//index will be incremented every
time we create a new account)
_ 3 digit random number: ranInt.nextInt(900)+ 100
{ print out all account information: name, sSN, accountNum-
ber, balance, rate: public void showInfo()
{ deposit money to the account: public void deposit(double
amount) (please call printBalance() at the end)
{ withdraw money from the account: public void withdraw(double
amount) (please call printBalance() at the end)
{ calculate and print out the accrued interest by using the rate/100*balance,
and update the new balance: public void compound() (please
call printBalance() at the end)
{ print out the new balance: public void printBalance()
3 Derived class: public class CheckingAccount extends Ac-
count
_ Constructor to initialize settings for the Checking account prop-
erties.
{ public CheckingAccount(String name, String sSN, double init-
Deposit) please call super() inside, and add \1" to the front of
your 12-digit accountNumber, 1 indicates Checking account.
Now your accountNumber should be a 13-digit number.
_ List any methods speci_c to the Checking Account
{ override showInfo() method: public void showInfo() (please
use super to call the base showInfo(), and also print out ac-
count type: Checking in the new showInfo())
{ set rate = BASE RATE*0.15: public void setRate()
4 Derived class: public class SavingAccount extends Ac-
count
_ Constructor to initialize settings for the Saving account properties
{ public SavingAccount(String name, String sSN, double init-
Deposit) please call super() inside, and add \2" to the front
of your 12-digit accountNumber, 2 indicates Saving account.
Now your accountNumber should be a 13-digit number.
_ List any methods speci_c to the Saving Account
{ override showInfo() method: public void showInfo() (please
use super to call the base showInfo(), and also print out ac-
count type: Saving in the new showInfo())
{ set rate = BASE RATE*0.25: public void setRate()
5 Driver class: public class AccountApp
Sample Driver class:
public class AccountApp {
public static void main(String[] args) {
// TODO Auto-generated method stub
CheckingAccount myAccount = new
CheckingAccount("Xin Yang","6857345856",1000);
myAccount.ShowInfo();
myAccount.deposit(2000);
myAccount.withDraw(4000);
myAccount.withDraw(1500);
myAccount.compound();
System.out.println("****************************************");
SavingAccount myAccount2 = new
SavingAccount("Ada Zhang","684321924",5000);
myAccount2.ShowInfo();
myAccount2.deposit(200);
myAccount2.withDraw(45000);
myAccount2.withDraw(550);
myAccount2.compound();
}
}
Sample Output:
Name: Xin Yang
sSN: 6857345856
Account Number: 1585610001183
Balance: 1000.0
Rate: 0.375%
Account Type: Checking Account
==============================
Deposit $2000.0
Your balance is now: $3000.0
================================
WithDraw $4000.0
Not enough balance available
Your balance is now: $3000.0
================================
WithDraw $1500.0
Your balance is now: $1500.0
================================
Accrued Interest is: $5.625
Your balance is now: $1505.625
================================
****************************************
Name: Ada Zhang
sSN: 684321924
Account Number: 2192410002737
Balance: 5000.0
Rate: 0.625%
Account Type: Saving Account
============================
Deposit $200.0
Your balance is now: $5200.0
================================
WithDraw $45000.0
Not enough balance available
Your balance is now: $5200.0
================================
WithDraw $550.0
Your balance is now: $4650.0
================================
Accrued Interest is: $29.0625
Your balance is now: $4679.0625
6 Comments in the whole programs (40 points)
· (1) Comments about the author information. (15 points)
· (2) Description of the programs. (15 points)
· (3) Comments for other necessary part (10 points)
7 Submission
Run your program make sure it is working correctly.
Please submit all of your source _les Account.java, CheckingAc-
count.java, SavingAccount.java, AccountApp.java to blackboard.