Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Given the original Code: abstract class Account { double balance; String name; p

ID: 3531166 • Letter: G

Question

Given the original Code:

abstract class Account {
double balance;
String name;

public double getBalance() {
return balance;
}

public void setBalance(double balance) {
this.balance = this.balance + balance;
if (this.balance < 0.0) {
System.out.println("Invalid balance");
this.balance = 0.0;
}

}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

Account() {
this.balance = 0.0;
this.name = "";
}

Account(double bal, String holderName) {
this.balance = bal;
this.name = holderName;
}

void credit(double amount) {
setBalance(amount);
}

void Debit(double amount) {
if (amount > getBalance()) {
System.out.println("Debit amount exceeded account balance.");
} else {
setBalance(getBalance() - amount);
}
}

abstract void print();

}

class SavingsAccount extends Account {

double interestRate;

SavingsAccount(String name, double bal, double rate) {
super(bal, name);
this.interestRate = rate;

}

double CalculateInterest() {
return interestRate * getBalance();
}

void print() {
System.out.println("Holder name:" + getName());
System.out.println("Interest Rate :" + interestRate);
System.out.println("Balance without interest:" + getBalance());
System.out.println("Balance with interest:"
+ (getBalance() + CalculateInterest()));
}

}

class CheckingAccount extends Account {

double feeCharged;

CheckingAccount(String name, double bal, double fee) {
super(bal, name);
this.feeCharged = fee;
}

void credit(double amount) {
super.credit(amount - feeCharged);
}

void Debit(double amount) {
super.Debit(amount + feeCharged);
}

void print() {
System.out.println("Holder name:" + getName());
System.out.println("Balance:" + getBalance());
System.out.println("Value for fee-charged-per-transaction:"+feeCharged);
}

}

public class TestAccount {

public static void main(String[] args) {
Account x=new SavingsAccount("Rohan",5322, 35);
x.print();
System.out.println("-------------------------");
Account y=new CheckingAccount("Rahul",2132,11);
y.print();



}

}

make changes to the AccountDriver.java file to include concepts of ArrayList and

polymorphism.

Create an ArrayList of type Account. Then through a series of menu options (see

sample input and output below) give the user options to Add/Delete/Modify an Account

as well as View All accounts. You should RESTRICT yourself to using the ArrayList of Accounts as

much as possible.

Sample Input (highlighted) and Output

Welcome to My Banking System. Enter

1 to Add Account

2 to Delete an Account

3 to Modify an Account

4 to View all Accounts

5 to Exit

6

Error in Input. Enter one of following.

1 to Add Account

2 to Delete an Account

3 to Modify an Account

4 to View all Accounts

5 to Exit

0

Error in Input. Enter one of following.

1 to Add Account

2 to Delete an Account

3 to Modify an Account

4 to View all Accounts

5 to Exit

1

Enter type of Account

1 for Savings Account

2 for Checking Account

3 to Return to Main Menu

2

Enter Account holder's name:Bob

Enter Account holder's Initial Balance:-200

Error in Input, Initial Balance cannot be negative! Enter Account holder's Initial

Balance:35000

Enter Checking Account's Fee Charged per Transaction:-2

Error in Input, Fee Charged per Transaction cannot be negative! Enter Checking

Account's Fee Charged per Transaction:1.75

Welcome to My Banking System. Enter

1 to Add Account

2 to Delete an Account

3 to Modify an Account

4 to View all Accounts

5 to Exit 1

Enter type of Account

1 for Savings Account

2 for Checking Account

3 to Return to Main Menu

2

Enter Account holder's name:Marley

Enter Account holder's Initial Balance:2000

Enter Checking Account's Fee Charged per Transaction:0.50

Welcome to My Banking System. Enter

1 to Add Account

2 to Delete an Account

3 to Modify an Account

4 to View all Accounts

5 to Exit

1

Enter type of Account

1 for Savings Account

2 for Checking Account

3 to Return to Main Menu

1

Enter Account holder's name:Sammy

Enter Account holder's Initial Balance:10000

Enter Savings Account's Initial Interest Rate:0.045

Welcome to My Banking System. Enter

1 to Add Account

2 to Delete an Account

3 to Modify an Account

4 to View all Accounts

5 to Exit

4

Account#1: ~~~Checking Account Details~~~

Name: Bob

Balance: 35000.0

Fee charged per Transaction: 1.75

Account#2: ~~~Checking Account Details~~~

Name: Marley

Balance: 2000.0

Fee charged per Transaction: 0.5

Account#3: ---Savings Account Details---

Name: Sammy

Balance (without interest): 10000.0

Balance (with interest): 10450.0

Interest Rate: 0.045

Welcome to My Banking System. Enter

1 to Add Account

2 to Delete an Account

3 to Modify an Account

4 to View all Accounts 5 to Exit

2

Enter Account Number to Delete0

Error in Input. Invalid Account Number. Enter Account Number to Delete

4

Error in Input. Invalid Account Number. Enter Account Number to Delete

2

Welcome to My Banking System. Enter

1 to Add Account

2 to Delete an Account

3 to Modify an Account

4 to View all Accounts

5 to Exit

4

Account#1: ~~~Checking Account Details~~~

Name: Bob

Balance: 35000.0

Fee charged per Transaction: 1.75

Account#2: ---Savings Account Details---

Name: Sammy

Balance (without interest): 10000.0

Balance (with interest): 10450.0

Interest Rate: 0.045

Welcome to My Banking System. Enter

1 to Add Account

2 to Delete an Account

3 to Modify an Account

4 to View all Accounts

5 to Exit

3

Enter Account Number to Modify1

Enter Account holder's NEW name. Enter SKIP to skip this step.SKIP

Enter Account holder's NEW Balance. Enter -1 to skip this step.400000

Enter Checking Account holder's NEW Fee Charged per Transaction. Enter -1 to skip

this step.-1

Welcome to My Banking System. Enter

1 to Add Account

2 to Delete an Account

3 to Modify an Account

4 to View all Accounts

5 to Exit

4

Account#1: ~~~Checking Account Details~~~

Name: Bob

Balance: 400000.0

Fee charged per Transaction: 1.75

Account#2: ---Savings Account Details---

Name: Sammy

Balance (without interest): 10000.0 Balance (with interest): 10450.0

Interest Rate: 0.045

Welcome to My Banking System. Enter

1 to Add Account

2 to Delete an Account

3 to Modify an Account

4 to View all Accounts

5 to Exit

5

Explanation / Answer

wrong ^ where did u get that code from terrible..

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote