Question: Q 1. Create a java project called Homework3_AccountTransactions, with a main class named TestAccountTransactions, and three classes: Account, CurrentAccount and Transaction, according to the following

Q 1. Create a java project called Homework3_AccountTransactions, with a main class named TestAccountTransactions, and three classes: Account, CurrentAccount and Transaction, according to the following descriptions: (A). Create the class Transaction according to the following UML diagram:

Q 1. Create a java project called Homework3_AccountTransactions, with a main class

(B). Create the class Account as the following: 1. Add all data fields, constructors, and methods of this class as shown in pages 36-37 in the Lab Manual. 2. Add a new private String data field called customerName; and its accessor and mutator methods. (C). Create the class CurrentAccount which inherits the Account class, with the following: 1. Add a new ArrayList data field named transactions of type Transaction, to store the transactions for account objects (i.e. withdraw and deposit operations). 2. Add an arg-constructor that is used to construct an account object with the specified customerName, id, balance, and annualInterestRate. This constructor must invoke the arg-constructor of Account class. 3. Override the withdraw and deposit methods to add a transaction to the transactions array list. (D). Write the programs main method to do the following: 1. Create an Account object for yourself with annual interest rate 1.5%, a 1000 SR balance, your id (1122), and your name. 2. Deposit 300 SR, and then 400 SR, and then 500 SR to your account. 3. Withdraw 100 SR, and then 200 SR, and then 150 SR from your account. 4. Print account summary that shows account holder name, interest rate, balance, and all transactions.

named TestAccountTransactions, and three classes: Account, CurrentAccount and Transaction, according to the

following descriptions: (A). Create the class Transaction according to the following UML

The get ter and setter methods for these data fields are provided in the class, but omitted in the UML diagram for brevity. Transaction - date: java.util.Date -type: char - amount: double -balance: double - description: String The date of this transaction. The type of the transaction, such as 'W' for withdrawal, 'D' for deposit The amount of the transaction. The new balance after this transaction. The description of this transaction. Construct a Transaction with the specified date, type, balance, and description. +Transaction(type: char, amount: double, balance: double, description: String) Here is Account class : page 36 class Account private int id = 0; private double balance = 0.0; private static double annualInterestRate = 0.0; private java.util.Date dateCreated; public Account() { dateCreated = new java.util.Date(); } public Account(int id, double balace) { this(); this.id = id; this.balance = balance; } public int getid) { return this.id; } public double getBalance() { return this.balance; } public double getAnnualinterestRate() { return annuallnterestRate; } public String getDateCreated() { return this.dateCreated.toString(); } public void setidint id) { this.id = id; } public void setBalance(double balance) { this.balance = balance; } public void setAnnualInterestRate(double annualinterestRate) { this.annualInterestRate = annualInterestRate; } public double getMonthlyInterestRate() { return (annualInterestRate / 100) / 12; } public double getMonthlyInterest() { return balance * getMonthlyInterestRate(); } public void withdraw(double amount) { this.balance = amount; } public void deposit(double amount) { this.balance += amount; } page 37 The Test Class for the above Account Class is: public class Test{ public static void main(String[] args) { Account account = new Account(1122, 20000); account.setAnnualInterestRate(4.5); account withdraw(2500.0); account.deposit(3000.0); System.out.println("Balance: $" + account.getBalance()); System.out.println("Monthly Interest: " + account.getMonthlyInterest()); System.out.println("Date Created: " + account.getDateCreated()); } }

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!