Question
(Part 1) 50 points : each method 10 points (The Account class) Design an abstract class named Account.java that contains: A protected data field id
(Part 1) 50 points : each method 10 points (The Account class) Design an abstract class named Account.java that contains: A protected data field id of the int type to store the account number (default 0). A protected data field name of the String type to store the name of the customer. A protected data field balance of type double to store the account balance (default 0). A protected Date data field named dateOpened that stores the date when the account was created. A protected data field transactions of type ArrayList that stores the transactions for the accounts. Each transaction is an instance of the Transaction class, which is defined as shown in next UML. A no-arg constructor that creates a default account. Add a new constructor that constructs an account with the specified name, id, balance, and sets the dateOpened to current date. The accessor and mutator functions for name, id, and balance. A accessor method to return dateOpened. An abstract method named withdraw that withdraws a specified amount from the account and add a transaction to the transactions array list. An abstract method named deposit that deposits a specified amount to the account and add a transaction to the transactions array list. A method named toString() to return a string in following format: Account id: 10023 Customer name: John Smith Account opened: Balance: $1000.00 Followed by list of all transactions
Account.java # id : int # name : String # balance : double # dateOpened : Date # transactions : ArrayList
Create two derived classes for checking and saving accounts. Part 3: (20 points) (The Checking class) Design a subclass of Account called Checking.java that contains: A constant double data field named OVERDRAFT_LIMIT. A checking account has an overdraft limit ($500) and acquires no interest. Implement and override withdraw() method from Account. Implement and override deposit() method from Account. Implement and override the toString() method from Account to return a string in the following format: Checkings Account id: 1003 Account opened: Balance: $5000.00 List of all transactions NOTE: Checking account cannot be overdrawn more than overdraftLimit. Reset balance. Every withdraw and deposit must be recorded as a transaction. Checkings.java # OVERDRAFT_LIMIT: double // default is 500 + Checkings() + Checkings(id:int, String name, balance:double) + withdraw(amount: double) : void + deposit(amount: double) : void + toString():string Part 4: (20 points) (The Saving class) Design a subclass of Account called Saving.java that contains: A data filed named annualInterestRate. The accessor and mutator functions for annualInterestRate. A function named getMonthlyInterest() that adds themonthly interest to the account balance. Add the transaction to Transactions. Return the monthly interest. Define and override the toString() function to return a string in the following format: Savings Account id: 1002 Account opened: Balance: 1000 Interest Rate: 6% List of all transactions
NOTE: Saving account cannot be overdrawn. Reset balance. Every withdraw and deposit must be recorded as a transaction. Savings.java # annualInterestRate : double + Savings() +Savings(id:int, String name, balance:double,rate:double) + getAnnualInterestRate(): double + setAnnualIntersetRate(rate:double) : void + getMonthlyInterest(): double + withdraw(amount:double) : void + deposit(amount: double) : void + toString(): string Test your classes with the given driver program. Sample output ********************************** Select an option: 1) Open a checking account 2) Checking deposit 3) Checking withdraw 4) Print checking account info. 5) Open a saving account 6) Saving deposit. 7) Saving withdraw. 8) Print monthly interest 9) Print saving account info. 10) Exit 1 ********************************** Enter customer name: John Smith
Enter initial balance for account # 1000: 1000 ********************************** Select an option: 1) Open a checking account 2) Checking deposit 3) Checking withdraw 4) Print checking account info. 5) Open a saving account 6) Saving deposit. 7) Saving withdraw. 8) Print monthly interest 9) Print saving account info. 10) Exit 2 ********************************** Enter account number: 1000 Enter deposit amount: 200 ********************************** Select an option: 1) Open a checking account 2) Checking deposit 3) Checking withdraw 4) Print checking account info. 5) Open a saving account 6) Saving deposit. 7) Saving withdraw. 8) Print monthly interest
9) Print saving account info. 10) Exit 3 ********************************** Enter account number: 1000 Enter withdraw amount: 2000 Error: Withdraw cancelled. Account over draft ********************************** Select an option: 1) Open a checking account 2) Checking deposit 3) Checking withdraw 4) Print checking account info. 5) Open a saving account 6) Saving deposit. 7) Saving withdraw. 8) Print monthly interest 9) Print saving account info. 10) Exit 3 ********************************** Enter account number: 1000 Enter withdraw amount: 1300 ********************************** Select an option:
1) Open a checking account 2) Checking deposit 3) Checking withdraw 4) Print checking account info. 5) Open a saving account 6) Saving deposit. 7) Saving withdraw. 8) Print monthly interest 9) Print saving account info. 10) Exit 2 ********************************** Enter account number: 1000 Enter deposit amount: 500 ********************************** Select an option: 1) Open a checking account 2) Checking deposit 3) Checking withdraw 4) Print checking account info. 5) Open a saving account 6) Saving deposit. 7) Saving withdraw. 8) Print monthly interest 9) Print saving account info. 10) Exit 4
********************************** Enter account number: 1000 Checkings Account id: 1000 Account opened: Wed Feb 01 10:15:09 PST 2023 Balance: $400.00 Transaction list Type Date Amount Balance Description D Wed Feb 01 10:15:09 PST 2023 $1000.00 $1000.00 Account opened D Wed Feb 01 10:15:18 PST 2023 $200.00 $1200.00 Deposit W Wed Feb 01 10:15:24 PST 2023 $2000.00 $1200.00 Overdrawn. Withdraw cancelled. W Wed Feb 01 10:15:31 PST 2023 $1300.00 $-100.00 Withdraw D Wed Feb 01 10:15:39 PST 2023 $500.00 $400.00 Deposit ********************************** Select an option: 1) Open a checking account 2) Checking deposit 3) Checking withdraw 4) Print checking account info. 5) Open a saving account 6) Saving deposit. 7) Saving withdraw. 8) Print monthly interest 9) Print saving account info. 10) Exit 5
********************************** Enter customer name: John Smith Enter initial balance for account # 1000: 1000 Enter annual interest rate for account # 1000: 6 ********************************** Select an option: 1) Open a checking account 2) Checking deposit 3) Checking withdraw 4) Print checking account info. 5) Open a saving account 6) Saving deposit. 7) Saving withdraw. 8) Print monthly interest 9) Print saving account info. 10) Exit 8 ********************************** Enter account number: 1000 Account 1000 earned $5.00 interest. ********************************** Select an option: 1) Open a checking account 2) Checking deposit 3) Checking withdraw 4) Print checking account info.
5) Open a saving account 6) Saving deposit. 7) Saving withdraw. 8) Print monthly interest 9) Print saving account info. 10) Exit 6 ********************************** Enter account number: 1000 Enter deposit amount: 200 ********************************** Select an option: 1) Open a checking account 2) Checking deposit 3) Checking withdraw 4) Print checking account info. 5) Open a saving account 6) Saving deposit. 7) Saving withdraw. 8) Print monthly interest 9) Print saving account info. 10) Exit 7 ********************************** Enter account number: 1000 Enter withdraw amount: 1300
Error: Account will be overdrawn. Withdraw cancelled. ********************************** Select an option: 1) Open a checking account 2) Checking deposit 3) Checking withdraw 4) Print checking account info. 5) Open a saving account 6) Saving deposit. 7) Saving withdraw. 8) Print monthly interest 9) Print saving account info. 10) Exit 7 ********************************** Enter account number: 1000 Enter withdraw amount: 800 ********************************** Select an option: 1) Open a checking account 2) Checking deposit 3) Checking withdraw 4) Print checking account info. 5) Open a saving account 6) Saving deposit. 7) Saving withdraw.
8) Print monthly interest 9) Print saving account info. 10) Exit 9 ********************************** Enter account number: 1000 Savings Account id: 1000 Account opened: Wed Feb 01 10:16:26 PST 2023 Balance: $405.00 Interest Rate: 6.0 Transaction list Type Date Amount Balance Description D Wed Feb 01 10:16:26 PST 2023 $1000.00 $1000.00 Account opened D Wed Feb 01 12:11:38 PST 2023 $5.00 $1005.00 Interest paid D Wed Feb 01 10:16:47 PST 2023 $200.00 $1205.00 Deposit W Wed Feb 01 10:17:04 PST 2023 $1300.00 $1205.00 Overdrawn. Withdraw cancelled. W Wed Feb 01 10:17:25 PST 2023 $800.00 $405.00 Withdraw ********************************** Select an option: 1) Open a checking account 2) Checking deposit 3) Checking withdraw 4) Print checking account info. 5) Open a saving account 6) Saving deposit.
7) Saving withdraw. 8) Print monthly interest 9) Print saving account info. 10) Exit
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