JAVA Programming 1. A bank offers two types of account for its customers, a savi
ID: 3707036 • Letter: J
Question
JAVA Programming
1. A bank offers two types of account for its customers, a savings account and a checking account. The savings account provides compound interest* and transfers money between accounts. The checking account provides withdrawal but no interest. Checking account holders should also maintain a minimum balance of $300 while a savings account should have a minimum balance of $100. If the balance falls below the minimum requirement, a service charge is imposed. Create a class Account that stores customer name, account number and account balance. From this derive two classes CheckingAccount and SavingsAccount. Include appropriate methods/instance variables to achieve the following tasks: (a) Deposit amount to an account (checking or savings) (b) Display the balance of an account (checking or savings) (c) Compute and deposit compound interest of a savings account (d) Permit withdrawal and update the balance accordingly (checking or savings). Check that the withdrawal should not be more than the account balance available. Impose a service charge, if the balance falls below the minimum balance required. Also, give user an option to transfer funds from the savings account (if sufficient balance available) when withdrawing from a checking account if there are insufficient funds available in the checking account. Update the savings balance accordingly.
* Compound Interest is calculated as: CI = P (1 + r/n) (nt)
Where: CI = Compound Interest P = the principal investment amount (the initial deposit) r = the annual interest rate (decimal) n = the number of times that interest is compounded per year t = the number of years the money is invested or borrowed
for Ref: https://www.thecalculatorsite.com/articles/finance/compound-interest-formula.php You may get input from user for each function. When your program starts, create a checking account object and a savings account object, and displays a menu of four functions that a user can select. Make your assumptions if necessary.
Explanation / Answer
// BankAccount.java abstract public class BankAccount { private int accountNumber; private double balance; private String customerName; private double minimumBalance; private static final double SERVICE_CHARGE = 10; public BankAccount(String cust, int number, double bal, double min) { accountNumber = number; balance = bal; customerName = cust; minimumBalance = min; } public int getAccountNumber() { return accountNumber; } public double getBalance() { return balance; } public String getCustomerName() { return customerName; } public double getMinimumBalance() { return minimumBalance; } public boolean withdraw(double amount) { if (balance - amount < 0) return false; else { balance = balance - amount; imposeServiceCharge(); return true; } } public void deposit(double amount) { balance = balance + amount; } public void displayBalance() { System.out.println("-------------------------------"); System.out.println("Customer: " + customerName); System.out.println("AccountNumber: " + accountNumber); System.out.println("Balance: $" + balance); System.out.println("-------------------------------"); } public void imposeServiceCharge() { if(getBalance()Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.