Question: Please modify the orginal code blow as the intrdoction: package bank; class Account { private String name; private long amount; Account(String name, long amount)

Please modify the orginal code blow as the intrdoction:

"

package bank;

class Account

{ private String name;

private long amount;

Account(String name, long amount) { this.name = name; setAmount(amount); }

void deposit(long amount) { this.amount += amount; }

String getName() { return name; }

long getAmount() { return amount; }

void setAmount(long amount) { this.amount = amount; } }

class SavingsAccount extends Account { SavingsAccount(long amount) { super("savings", amount); } }

class CheckingAccount extends Account { CheckingAccount(long amount) { super("checking", amount); }

void withdraw(long amount) { setAmount(getAmount() - amount); } }

//add the class CertificateOfDeposit class CertificateOfDeposit extends Account { CertificateOfDeposit(long amount) { super("Certificate Of Deposit", amount); } } //add the Child class Mortgage class Mortgage extends Account { Mortgage(long amount) { super("Mortgage", amount); }

void withdraw(long amount) { setAmount(getAmount() - amount); } }

class AccountDemo { public static void main(String[] args) { SavingsAccount sa = new SavingsAccount(10000); System.out.println("account name: " + sa.getName()); System.out.println("initial amount: " + sa.getAmount()); sa.deposit(5000); System.out.println("new amount after deposit: " + sa.getAmount()); System.out.println("");

CheckingAccount ca = new CheckingAccount(20000); System.out.println("account name: " + ca.getName()); System.out.println("initial amount: " + ca.getAmount()); ca.deposit(6000); System.out.println("new amount after deposit: " + ca.getAmount()); ca.withdraw(3000); System.out.println("new amount after withdrawal: " + ca.getAmount()); System.out.println(""); //Certificate of deposit information CertificateOfDeposit cd = new CertificateOfDeposit(150000); System.out.println("account name: " + cd.getName()); System.out.println("initial amount: " + cd.getAmount()); cd.deposit(50000); System.out.println("new amount after deposit: " + cd.getAmount()); System.out.println(""); System.out.println(""); //Mortgate information } }"

2) Now, take the code and modify it to include two new subclasses: CertificateOfDeposit (which is similar to the SavingsAccount class), and Mortgage (which is similar to theCheckingAccount class).For the CertificateofDeposit class: assume an initial balance of 150,000, and an additional deposit of 50,000 upon renewal of the savings product.

For the Mortgage class: assume an initial balance of 250,000, and a payment of 50,000 to reduce the mortgage.

Place the modified code and a snapshot of the output in the lab template form.

3) Make the CertificateOfDeposit class a subclass of the SavingsAccount class. [Hint: you might need to overload the constructor of the SavingsAccount class]. Place the modified code and a snapshot of the output in the lab template form for this assignment.

Please use java code as well, and prove the Excel Spreadsheet to show the computation of the results as well

Thank you very much

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!