Checking and Savings accounts may not be the only types of accounts. Moreover, different account types may have different rules for withdrawal, interest calculation, etc. To support this, do the following:
Create an abstraction (i.e., an interface or abstract class with no concrete implementation) to represent a generic bank account.
All bank accounts have an account number, account holder(s) and a current balance. The abstraction must have functions to retrieve all these pieces of information.
The abstraction must contain a function to add a new account holder.
The abstraction must contain functions to support deposit and withdraw actions. The withdraw function must be capable of throwing an exception if there is insufficient account balance.
The abstraction must contain a function to calculate interest using the current account balance and an interest rate and add that interest to the existing account balance. [Note: you can assume that some other entity is responsible for calling this function at the desired frequency, e.g., daily, monthly, etc.]
Create a class with a function that automatically generates a unique bank account number. [Hint: the simplest approach is to use a static or class level attribute and corresponding function].
Create a concrete implementation of the abstraction created in Step a to represent a Checking account. Assume these rules:
It must be possible to create a Checking account with or without an initial deposit. The account number must be automatically generated using the generator from Step b.
Any withdrawal that does not reduce the account balance to less than 0 is considered valid. If an invalid withdrawal occurs, an exception must be thrown indicating that the balance is insufficient to perform the withdrawal.
A Checking account has a flat interest rate of 0.01%.
Create a concrete implementation of the abstraction created in Step a to represent a Savings account. Assume the following rules:
A Savings account requires a minimum initial deposit of $100. The account number must be automatically generated using the generator from Step b.
A Savings account must maintain a minimum balance of $100 at all times. Any withdrawal that would make the balance go below this minimum amount is considered invalid. If an invalid withdrawal occurs, an exception must be thrown indicating that the balance is insufficient to perform the withdrawal.
A Savings account has the following interest rates:
< $2,000 balance: 0.01%
>= $2,000 & < $12,000 balance: 0.05%
>= $12,000 balance: 0.1%
Create a bank account demo class. In this class, write a driver/main function to demonstrate your implementation. In this main function, do the following:
Create a Checking account for Julio Perez with no initial deposit. Once the account is created, display the (generated) account number for the user’s benefit.
Perform the following operations on Julio’s Checking account - after each operation below, display the current balance in the account:
Deposit $1500 into the account.
Withdraw $150 from the account.
Perform interest accumulation (i.e., call the function that calculates and adds interest).
Withdraw $750 from the account.
Perform interest accumulation.
Create a Savings account for Sasha Ivanov with an initial deposit of $600. Once the account is created, display the (generated) account number for the user’s benefit.
Perform the following operations on Sasha’s Savings account - after each operation below, display the current balance in the account:
Perform interest accumulation.
Deposit $150 into the account.
Perform interest accumulation.
Withdraw $600 from the account.
The following bold text contains all the code and the description of code is given as comments:
CODE:
AbstractAccount.java
import java.util.ArrayList;
//This is the abstract class to represent a generic bank account.
public abstract class AbstractAccount {
protected final int accountNo;
protected ArrayList<String> holderNames;
protected double balance;
//This is the parameterized constructor
public AbstractAccount(String holderNames, double balance) {
this.accountNo = new AccountNumber().getNewAccountNo();
this.holderNames = new ArrayList<>();
this.holderNames.add(holderNames);
this.balance = balance;
}
//the following are the abstract functions that are needed to be implemented concretely in the savings and the checking account class as mentioned in the problem statement.
protected abstract int getAccountNo();
protected abstract ArrayList<String> getHolderNames();
protected abstract double getBalance();
protected abstract void addNewAccountHolder(String holderName);
public abstract void deposit(double depAmount);
public abstract void withdraw(double amount) ;
public abstract void addInterest();
}
AccountNumber.java
//This is the class with a function that automatically generates a unique bank account number
public class AccountNumber {
static int accountNo = 100000;
public int getNewAccountNo(){
return ++accountNo;
}
}
InsufficientBalanceException.java
//This is the class to create the exception for Insufficient balance message
public class InsufficientBalanceException extends Exception {
public InsufficientBalanceException(String cause){
super(cause);
}
}
CheckingAccount.java
import java.util.ArrayList;
//This is the class for the Checking Account
public class CheckingAccount extends AbstractAccount{
//This is the constructor
public CheckingAccount(String holderNames, double initialBalance) {
super(holderNames,initialBalance);
}
//This method returns the account number
@Override
protected int getAccountNo() {
return super.accountNo;
}
//This method helps to retrieve the names of all the account holder names associated with the account
@Override
protected ArrayList<String> getHolderNames(){
return super.holderNames;
}
//This method helps to retrieve the balance.
@Override
protected double getBalance() {
return super.balance;
}
//This method helps to add a new account holder name to the account
@Override
protected void addNewAccountHolder(String holderName){
super.holderNames.add(holderName);
}
//This method helps to deposit some amount to the account
@Override
public void deposit(double depAmount){
super.balance+=depAmount;
System.out.println("Deposited : $"+depAmount);
}
//This method helps to withdraw some amount from the account and throws an exception is the balance falls below $0
@Override
public void withdraw(double amount) {
if(amount<=super.balance){
super.balance-=amount;
System.out.println("Withdrawn : $"+amount);
}
else{
try {
throw new InsufficientBalanceException("Error...Insufficient balance!");
} catch (InsufficientBalanceException e) {
e.printStackTrace();
}
}
}
//This method helps to add the interest to the balance
@Override
public void addInterest(){
double interest = super.balance*0.01;
super.balance=super.balance + interest;
System.out.println("Interest Added @0.01 : $"+interest);
}
}
SavingsAccount.java
import java.util.ArrayList;
//This is the class for the Savings Account
public class SavingsAccount extends AbstractAccount{
//This is the constructor
public SavingsAccount(String holderNames, double initialBalance) {
super(holderNames, initialBalance);
if(initialBalance<100){
try {
throw new InsufficientBalanceException("Error..Savings Account requires a minimum initial deposit of $100");
} catch (InsufficientBalanceException e) {
e.printStackTrace();
}
}
}
//This method returns the account number
@Override
protected int getAccountNo() {
return super.accountNo;
}
//This method helps to retrieve the names of all the account holder names associated with the account
@Override
protected ArrayList<String> getHolderNames(){
return super.holderNames;
}
//This method helps to retrieve the balance.
@Override
protected double getBalance() {
return super.balance;
}
//This method helps to add a new account holder name to the account
@Override
protected void addNewAccountHolder(String holderName){
super.holderNames.add(holderName);
}
//This method helps to deposit some amount to the account
@Override
public void deposit(double depAmount){
super.balance+=depAmount;
System.out.println("Deposited : $"+depAmount);
}
//This method helps to withdraw some amount from the account and throws an exception is the balance falls below $100
@Override
public void withdraw(double amount) {
if(amount+100<=super.balance){
super.balance-=amount;
System.out.println("Withdrawn : $"+amount);
}
else{
try {
throw new InsufficientBalanceException("Error...Insufficient balance!");
} catch (InsufficientBalanceException e) {
e.printStackTrace();
}
}
}
//This method helps to add the interest to the balance
@Override
public void addInterest(){
double interest;
float rate;
if(super.balance<2000){
interest = super.balance*0.01;
rate = 0.01f;
}else if(super.balance>=2000 && super.balance<12000){
interest = super.balance*0.05;
rate = 0.05f;
}else{
interest = super.balance*0.1;
rate = 0.1f;
}
super.balance = super.balance+interest;
System.out.println("Interest Added @"+rate+" : $"+interest);
}
}
BankAccountDemo.java:
//This is the main driver class and this demonstrates the implementation of banking system created.
public class BankAccountDemo {
public static void main(String[] args) {
//for Julio Perez' account
AbstractAccount account1 = new CheckingAccount("Julio Perez",0);
System.out.println("Your account Number is : "+ account1.getAccountNo());
account1.deposit(1500);
System.out.println("Account Balance : $"+account1.getBalance());
account1.withdraw(150);
System.out.println("Account Balance : $"+account1.getBalance());
account1.addInterest();
System.out.println("Account Balance : $"+account1.getBalance());
account1.withdraw(750);
System.out.println("Account Balance : $"+account1.getBalance());
account1.addInterest();
System.out.println("Account Balance : $"+account1.getBalance());
System.out.println();
//for Sasha Ivanov' account
AbstractAccount account2 = new SavingsAccount("Sasha Ivanov",600);
System.out.println("Your account Number is : "+ account2.getAccountNo());
System.out.println("Account Balance : $"+account2.getBalance());
account2.addInterest();
System.out.println("Account Balance : $"+account2.getBalance());
account2.deposit(150);
System.out.println("Account Balance : $"+account2.getBalance());
account2.addInterest();
System.out.println("Account Balance : $"+account2.getBalance());
account2.withdraw(600);
System.out.println("Account Balance : $"+account2.getBalance());
}
}
OUTPUT:

Checking and Savings accounts may not be the only types of accounts. Moreover, different account types...
C++
Banks offer various types of accounts, such as savings,
checking, certificate of deposits, and money market, to attract
customers as well as meet their specific needs. Two of the most
commonly used accounts are savings and checking. Each of these
accounts has various options. For example, you may have a savings
account that requires no minimum balance but has a lower interest
rate. Similarly, you may have a checking account that limits the
number of checks you may write....
Need some help with this C++ code. Please screenshot the code if possible. Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment also aims at creating a C++ project to handle multiple files (one header file and two .cpp files) at the same time. Remember to follow documentation and variable name guidelines. Create a C++ project to implement a simplified banking system. Your bank is small, so it can have a maximum of...
JAVA PLEASE Create a class called Account with the following instance data Integer id Double balance Provides the following methods Default constructor (defaults balance to 100) Constructor with parameters for the ID and the starting balance Accessor and mutator methods for id and balance Method to perform a withdrawal Method to perform a deposit Create a class called Bank which has an array of Account objects. This class will manage the accounts. It must provide methods Do withdrawal Do deposits...
Purpose: Demonstrate the ability to create and manipulate classes, data members, and member functions. This assignment also aims at creating a C++ project to handle multiple files (one header file and two .cpp files) at the same time. Remember to follow documentation and variable name guidelines. Create a C++ project to implement a simplified banking system. Your bank is small, so it can have a maximum of 100 accounts. Use an array of pointers to objects for this. However, your...
c++ help please. Savings accounts: Suppose that the bank offers two types of savings accounts: one that has no minimum balance and a lower interest rate and another that requires a minimum balance but has a higher interest rate (the benefit here being larger growth in this type of account). Checking accounts: Suppose that the bank offers three types of checking accounts: one with a monthly service charge, limited check writing, no minimum balance, and no interest; another with no...
Create an Inheritance hierarchy that a bank may use to represent customer's bank accounts (Checking and Savings), this includes a GUI user interface that allows user to login, and deposit or withdraw, and application to display the transaction and final balance. All the bank customers can: - Create a new account - Deposit (Credit) money into their account and/or withdraw (debit) money from their account. - Application should expect user to login to their account using login/password Create necessary classes...
Should be in C#
Create an inheritance hierarchy that a bank might use to
represent customers’ bank accounts. All customers at this back can
deposit (i.e. credit) money into their accounts and withdraw (i.e.
debit) money from their accounts. More specific types of accounts
also exist. Savings accounts, for instance, earn interest on the
money they hold. Checking accounts, on the other hand, charge a fee
per transaction.
Create base class Account and derived classes SavingsAccount and
CheckingAccount that inherit...
JAVA PROGRAMMING LANGUAGE!!!! JAVA PROGRAMMING LANGUAGE!!!! JAVA PROGRAMMING LANGUAGE!!!! Bank Account and Savings Account Classes Design an abstract class named BankAccount to hold the following data for a bank account: • Balance • Number of deposits this month • Number of withdrawals • Annual interest rate • Monthly service charges The class should have the following methods: Constructor: The constructor should accept arguments for the balance and annual interest rate. deposit: A method that accepts an argument for the amount of...
Project 9-2: Account Balance Calculator Create an application that calculates and displays the starting and ending monthly balances for a checking account and a savings account. --->Console Welcome to the Account application Starting Balances Checking: $1,000.00 Savings: $1,000.00 Enter the transactions for the month Withdrawal or deposit? (w/d): w Checking or savings? (c/s): c Amount?: 500 Continue? (y/n): y Withdrawal or deposit? (w/d): d Checking or savings? (c/s): s Amount?: 200 Continue? (y/n): n Monthly Payments and Fees Checking fee: $1.00 Savings...