Description of the problem: make a program that tests the implementation of all the classes. Before doing transaction, user should be prompted the type of his bank account:  Savings or Checking.  This is in a form of menu.  After indicating the account type,  user should be prompted to select transaction from a menu:  deposit, withdraw, Inquire, or transfer.  To check the implementation of addPeriodicInterest in Savings account, add the method MonthEnd() in your program.  This method should be called so that interest be added to the balance of this saving account at the end of the month. Design your program such that all methods in both child class and parent class are tested. To make your program more realistic, your program should allow user do transactions until no more transactions needed.  Use a loop statement for this process.

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

Description of the problem: make a program that tests the implementation of all the classes. Before doing transaction, user should be prompted the type of his bank account:  Savings or Checking.  This is in a form of menu.  After indicating the account type,  user should be prompted to select transaction from a menu:  deposit, withdraw, Inquire, or transfer.  To check the implementation of addPeriodicInterest in Savings account, add the method MonthEnd() in your program.  This method should be called so that interest be added to the balance of this saving account at the end of the month. Design your program such that all methods in both child class and parent class are tested.

To make your program more realistic, your program should allow user do transactions until no more transactions needed.  Use a loop statement for this process. 

 

Below is initial code. Try to improve it and complete it with the Main program that satisfy the description of the problem. Also try to fix the redlines 

No sample output because my initial code has some errors and I don't know how to fix them, but based on the description of the problem, it should display simple bank account that implements all the methods and classes.


public class BankAccount {
    private double balance;
    
    public BankAccount(double initialAmount) {
        balance =  initialAmount;
    }
    
    public void deposit(double amount) {
        balance += amount;
    }
    
    public void withdraw(double amount) {
        balance -= amount;
    }
    
    public double getBalance() {
        return balance;
    }
    
    public void transfer(BankAccount Other, double amount) {
        withdraw(amount);
        other.deposit(amount);
    }
}
public class SavingsAccount extends BankAccount {
    private double interestRate;
    
    public SavingsAccount(double rate) {
        interestRate = rate;
    }
    public SavingsAccount(double rate, double initialAmount) {
        super(initialAmount);
        interestRate = rate;
    }
    
    public void addPeriodicInterest() {
        double interest = getBalance() * interestRate / 100.0;
        deposit(interest);
    }
}
public class CheckingAccount extends BankAccount {
    private static final int FREE_TRANSACTIONS = 3;
    private static final double TRANSACTION_FEE = 0.50;
    private int transactionCount;
    
    public CheckingAccount() {
        transactionCount = 0;
    }
    
    public CheckingAccount(double initialAmount) {
        super(initialAmount);
        transactionCount = 0;
    }
    
    public void withdraw (double amount) {
        super.withdraw(amount);
        transactionCount++;
    }
    
    public void deposit(double amount) {
        super.deposit(amount);
        transactionCount++;
    }
    
    public void deductfees() {
        if (transactionCount > FREE_TRANSACTIONS) {
            double fee = TRANSACTION_FEE * (transactionCount - FREE_TRANSACTIONS);
            super.withdraw(fee);
        }
        transactionCount = 0;
    }
public static void main(String[] args) {
    //put your code here
    }
}

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Unreferenced Objects
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
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