Question: For this project, you will start off by creating a back up of project 5 (copy and store project 5 before making any changes to

For this project, you will start off by creating a back up of project 5 (copy and store project 5 before making any changes to it). Then, open project 5 in Netbeans, right click on the project and rename the project to project 6.

For this project, you shall define a new class BankDatabase. The BankDatabase contains the bank account information for all accounts including saving accounts and checking accounts. The customer names are passed as firstname lastname. Your application must split the string into two separate strings for first name and last name (Hint: use the split() method). If you decide to use an array to store the bank accounts, you can assume there will be maximum of 100 bank accounts in the Bank Database. Alternatively, you can consider using an ArrayList in which case its size can grow automatically as new bank accounts are added. BankDatabase class implements the following methods:

BankDatabase() constructor

void creatCheckingAccount(String customerName, String ssn, float deposit) This method creates a checking account

void creatSavingAccount(String customerName, String ssn, float deposit) This method creates a saving account

void print() This method prints the bank account information in the database in ascending order of the account balances.

void applyIntrest This methods applies interest to all bank accounts. The interest for each type of account is the same as project 5.

Make the following updates to the BankAccount super class:

1) Make the BankAccount super class an abstract class and make applyInterest an abstract method.

2) The BankAccount super class shall implement the Comparable Interface. You shall implement the compareTo method to provide the means to sort the bank accounts in the ascending order of the account balance.

Identify the objects for this application and define each class attribute with proper access qualifier. You can use the main method shown below to test your application. The expected output is also provided.

public class BankApp {

public static void main(String[] args) {

BankDatabase acctDatabase = new BankDatabase();

acctDatabase.createCheckingAccount("Alin Parker", "123-45-6789", 20000.0f);

acctDatabase.createSavingAccount("Mary Jones", "987-65-4321", 15000.0f);

acctDatabase.createSavingAccount("John Smith", "123-45-6789", 12000.0f);

acctDatabase.print();

acctDatabase.applyInterest();

acctDatabase.print();

}

======= expected output =============

Succesfully created account for Alin Parker Account Number 5435736518

Succesfully created account for Mary Jones Account Number 3612979581

Succesfully created account for John Smith Account Number 6998050883

John Smith, accn #: 6998050883, Balance $12000.0

Mary Jones, accn #: 3612979581, Balance $15000.0

Alin Parker, accn #: 5435736518, Balance $20000.0

John Smith, accn #: 6998050883, Balance $12600.0

Mary Jones, accn #: 3612979581, Balance $15750.0

Alin Parker, accn #: 5435736518, Balance $20200.0

................................................................................................................................................

project 5:

package bank;

//Customer class public class Customer { private String firstName; private String lastName; private String ssn;

//Constructor Customer(){ }

//setter and getter method public String getFirstName() { return firstName; } public void setFirstName(String firstName) { this.firstName = firstName; } public String getLastName() { return lastName; } public void setLastName(String lastName) { this.lastName = lastName; } public String getSsn() { return ssn; } public void setSsn(String ssn) { if((ssn.charAt(3) != '-')||(ssn.charAt(6) != '-')|| ssn.length()!=11) System.out.println("Invalid SSN."); else this.ssn = ssn; } }

///////////////////////////////

package bank;

//BankAccount class public abstract class BankAccount {

protected float balance; protected Customer customer; protected long accountNumber; public float getBalance() { return balance; }

public void setBalance(float balance) { this.balance = balance; }

public Customer getCustomer() { return customer; }

public void setCustomer(Customer customer) { this.customer = customer; }

public long getAccountNumber() { return accountNumber; }

public void setAccountNumber(long accountNumber) { this.accountNumber = accountNumber; }

//Constructors BankAccount (){ }

BankAccount(String firstName, String lastName, String ssn,float balance) { customer = new Customer(); customer.setFirstName(firstName); customer.setLastName(lastName); customer.setSsn(ssn); this.balance = balance; }

public void deposit(float amount) { balance = balance + amount; System.out.println(customer.getFirstName() + " " + customer.getLastName() + " deposited $" + amount + ". Current Balance $" + balance);

}

public void withdraw(float amount) { if (balance >= amount) { balance = balance - amount; System.out.println(customer.getFirstName() + " " + customer.getLastName() + " withdrew $" + amount + ". Current Balance $" + balance); } if (balance < amount) { System.out.println("Unable to withdraw " + amount + " for " + customer.getFirstName() + " " + customer.getLastName() + " due to insufficient funds."); } } public abstract float applyInterest();

}

//////////////////////

package bank;

//SavingAccount class public class SavingAccount extends BankAccount {

public SavingAccount() { }

public SavingAccount(String firstName, String lastName, String ssn, float balance) { super(firstName, lastName, ssn, balance); System.out.println("Successfully created account for " + firstName + " " + lastName + " " + accountNumber); System.out.println(firstName + " " + lastName + ", Balance $" + balance); }

public float applyInterest () { balance += ((balance - 10000) * 5)/100; return balance; }

long accountNumber() { long accountNumber = (long) Math.floor(Math.random() * 9000000000L) + 1000000000L; return accountNumber; }

float checkBalance() { System.out.println(customer.getFirstName() + " " + customer.getLastName() + ", Balance $" + balance); return balance; } }

/////////////////////////////

package bank;

//CheckingAccount class public class CheckingAccount extends BankAccount {

public CheckingAccount() { }

public CheckingAccount(String firstName, String lastName, String ssn, float balance) { super(firstName, lastName, ssn, balance); System.out.println("Successfully created account for " + firstName + " " + lastName + " " + accountNumber()); }

public float applyInterest () { balance += ((balance - 10000)*2)/100; return balance; }

float checkBalance() {

System.out.println(customer.getFirstName() + " " + customer.getLastName() + ", Balance $" + balance);

return balance; }

long accountNumber() { long accountNumber = (long) Math.floor(Math.random() * 9000000000L) + 1000000000L; return accountNumber; } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!