Question
I need help with this coding assignment please! The lab is to be done in JAVA. Please leave comments so that I can follow along
I need help with this coding assignment please! The lab is to be done in JAVA. Please leave comments so that I can follow along and understand what you did.
Part One: Interface Design
Write an interface called Banking.java, to include the methods deposit, withdraw and getBalance.
Part Two: Class Design
Create the following 3 classes to implement Banking:
-
CheckingAccount
-
SavingsAccount
-
RetirementAccount
All classes should have a toString() method to show the state of all pertinent data fields.
-
CheckingAccount only contains balance.
-
SavingsAccount contains balance and interest.
-
RetirementAccount contains balance, interest, and age of the account
The owner of a RetirementAccount is only allowed to withdraw from the account when it is over 25 years old.
Part Three - Testing
Run BankDriver.java
public class BankDriver { public static void main(String[] args) { Banking[] myAccounts = new Banking[4]; myAccounts[0] = new CheckingAccount(200.00); myAccounts[1] = new SavingsAccount(500.00, 0.5); myAccounts[2] = new RetirementAccount(20000, 4.3, 10); myAccounts[3] = new RetirementAccount(500000, 3.2, 35); System.out.println("INITIAL ACCOUNTS"); for(Banking account: myAccounts) { System.out.println(account); } System.out.println(); myAccounts[0].withdraw(75.75); myAccounts[1].deposit(100.00); myAccounts[2].withdraw(350.25); myAccounts[3].withdraw(250); System.out.println("TRANSACTIONS ROUND 1"); for(Banking account: myAccounts) { System.out.println(account); } System.out.println(); myAccounts[0].deposit(50.00); myAccounts[1].withdraw(500.00); myAccounts[2].deposit(30.00); myAccounts[3].deposit(100.00); System.out.println("TRANSACTIONS ROUND 2"); for(Banking account: myAccounts) { System.out.println(account); } System.out.println(); } }
Make sure your output matches this example.
INITIAL ACCOUNTS Checking Account Balance: $200.0 Savings Account Balance: $500.0, Interest Rate: 0.5% Retirement Account Balance: $20000.0, Interest Rate: 4.3%, Age of account: 10 years
Retirement Account Balance: $500000.0, Interest Rate: 3.2%, Age of account: 35 years
TRANSACTIONS ROUND 1 Checking Account Balance: $124.25 Savings Account Balance: $600.0, Interest Rate: 0.5% Retirement Account Balance: $20000.0, Interest Rate: 4.3%, Age of account: 10 years
Retirement Account Balance: $499750.0, Interest Rate: 3.2%, Age of account: 35 years
TRANSACTIONS ROUND 2 Checking Account Balance: $174.25 Savings Account Balance: $100.0, Interest Rate: 0.5% Retirement Account Balance: $20030.0, Interest Rate: 4.3%, Age of account: 10 years
Retirement Account Balance: $499850.0, Interest Rate: 3.2%, Age of account: 35 years
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started