In Java Write a bank account program that handles bank account balances for an array of bank accounts. There are two types of bank accounts ─ checking and savings. Use this UML class diagram: BankAccount Checking Savings Implement the following classes and methods. BankAccount class: Instance variable: balance deposit method ─ add the given amount to the current balance. Withdraw method ─ subtract the given amount from the current balance. Don’t allow the balance to go below zero. If the balance does go below zero, change the balance to zero. display method ─ This must be an abstract method. Checking class: No new instance variables. writeACheck method ─ subtract the given amount from the current balance and then subtract an additional $1 as part of a service fee. display method ─ print the type of account, checking, and then the balance (with standard currency format). Study the output for details. Savings class: Instance variable: intRate (interest rate) addInterest method ─ calculate the interest by multiplying the intRate by the current balance. Add the interest to the balance. display method ─ print the type of account, savings, and then the balance (with standard currency format). Provide appropriate constructors and additional methods as necessary. Study the given main method and output for details. Hint: Do not allow the balance to go below zero. If the balance does go below zero, change the balance to zero. Provide a driver class that tests your three classes. Your driver class should contain this main method: public static void main(String[] args) {  BankAccount[] accounts = new BankAccount[100];  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(210);  accounts[2].deposit(100);  ((Checking) accounts[2]).writeACheck(50);  for (int i=0; i

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

In Java

Write a bank account program that handles bank account balances for an array of bank accounts. There are
two types of bank accounts ─ checking and savings. Use this UML class diagram:
BankAccount
Checking Savings
Implement the following classes and methods.
BankAccount class:
Instance variable:
balance
deposit method ─ add the given amount to the current balance.
Withdraw method ─ subtract the given amount from the current balance. Don’t allow the balance to
go below zero. If the balance does go below zero, change the balance to zero.
display method ─ This must be an abstract method.
Checking class:
No new instance variables.
writeACheck method ─ subtract the given amount from the current balance and then subtract an
additional $1 as part of a service fee.
display method ─ print the type of account, checking, and then the balance (with standard currency
format). Study the output for details.
Savings class:
Instance variable:
intRate (interest rate)
addInterest method ─ calculate the interest by multiplying the intRate by the current balance. Add
the interest to the balance.
display method ─ print the type of account, savings, and then the balance (with standard currency
format).

Provide appropriate constructors and additional methods as necessary. Study the given main method and
output for details. Hint: Do not allow the balance to go below zero. If the balance does go below zero,
change the balance to zero.
Provide a driver class that tests your three classes. Your driver class should contain this main method:
public static void main(String[] args)
{
 BankAccount[] accounts = new BankAccount[100];
 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(210);
 accounts[2].deposit(100);
 ((Checking) accounts[2]).writeACheck(50);

 for (int i=0; i<accounts.length && accounts[i] != null; i++)
 {
 accounts[i].display();
 }
} // end main

Output:
Savings account balance = $1,050.00
Checking account balance = $50.00
Checking account balance = $49.00

Expert Solution
steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education