Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a bank account program that handles account balances for an array of bank accounts. There are two types of accounts: Checking and Savings. Each

Write a bank account program that handles account balances for an array of bank accounts. There are two types of accounts: Checking and Savings. Each of these accounts should allow for deposits, withdrawals, and the display of account balances. Balances should be displayed by printing the type of account (checking or savings) and then the balance. For the checking account, you should also be able to write a check - but the bank will take a dollar for every check it processes as a service fee. Additionally, the savings account should be able to compound interest by multiplying its interest rate by the balance and adding that to the current balance. Provide appropriate constructors and additional methods as necessary. Study the given main method and output for details. Write a driver class to test your code. The driver class should contain the main method below. Replace the comment with code that creates the exact same test cases but uses a Java ArrayList instead of an old-fashioned array to store the three instances. Also, improve upon the code that runs through the test cases (in the ArrayList) to display them. Leave the existing code (below) that deals with the array, as-is. public static void main(String[] args) { BankAccount[] accounts = new BankAccount[3]; accounts[0] = new Savings(1100, .05); accounts[0].deposit(100); accounts[0].withdraw(200); ((Savings) accounts[0]).addInterest(); accounts[1] = new Checking(100); accounts[1].deposit(50); accounts[2] = new Checking(200); accounts[2].withdraw(100); accounts[2].deposit(75); ((Checking) accounts[2]).writeACheck(50); for(int i = 0; i < accounts.length && accounts[i] != null; i++) { accounts[i].display(); } System.out.println(ArrayList Results:); // INSERT ARRAYLIST CODE HERE } Expected Output: Savings account balance = $1050.00 Checking account balance = $150.00 Checking account balance = $124.00 ArrayList Results: Savings account balance = $1050.00 Checking account balance = $150.00 Checking account balance = $124.00

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Temporal Databases Research And Practice Lncs 1399

Authors: Opher Etzion ,Sushil Jajodia ,Suryanarayana Sripada

1st Edition

3540645195, 978-3540645191

Students also viewed these Databases questions

Question

LO 1-3 What the costs of communication are.

Answered: 1 week ago