In: Computer Science
THIS IS JAVA PROGRAMMING
Design a class named Account (that contains
1. A private String data field named id for the account (default 0).
2. A private double data field named balance for the account (default 0).
3. A private double data field named annualInterestRate that stores the current interest rate (default 0).
4. A private Date data field named dateCreated that stores the date when the account was created.
5. A no-arg constructor that creates a default account.
6. A constructor that creates an account with the specified id and initial balance.
7. The accessor and mutator methods for id, balance, and annualInterestRate.
8. The accessor method for dateCreated.
9. A method named getMonthlyInterestRate() that returns the monthly interest rate.
10. A method named withdraw that withdraws a specified amount from the account and returns a boolean based on sufficient funds.
11. A method named deposit that deposits a specified amount into the account, and returns a boolean
12. A method call toString() that returns a “nicely formatted” string similar to the following:
ID: 1234567
Balance: $53,823.27
InterestRate: 0.036
Date Account Created: 10/23/2018
Draw the UML diagram for the class. Implement the class (write the Java code as specified by the UML diagram). Use the Lab7 test program (attached to dropbox) that creates an Account object with an account ID of 5544, a balance of $45,000.00 and an annual interest rate of 3.6%. Use the withdraw method to withdraw $3,700.00, use the deposit method to deposit $2,200.00 and print the balance, the monthly interest, and the date this account was created. Keep in mind that while this tester has hard-coded values, the Account class should be usable by a full-blown application. As such, refrain from having Account.java print messages or accepting input from the keyboard.
Note: Could you plz go through this code and let me
know if u need any changes in this.Thank You
=================================
===========================================
// Account.java
import java.text.SimpleDateFormat;
import java.util.Date;
public class Account {
private int id;
private double balance;
private double annualInterestRate;
private Date dateCreated;
public Account() {
this.id = 0;
this.balance = 0;
this.annualInterestRate = 0;
this.dateCreated = new
Date();
}
public Account(int id, double initialBal) {
this.id = id;
this.balance = initialBal;
this.annualInterestRate = 0;
this.dateCreated = new
Date();
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public double getAnnualInterestRate() {
return annualInterestRate;
}
public double getMonthlyInterestRate() {
return
annualInterestRate/1200;
}
public void setAnnualInterestRate(double
annualInterestRate) {
this.annualInterestRate =
annualInterestRate;
}
public double getMonthlyInterest() {
double
interest=balance*(annualInterestRate / 1200);
this.balance+=interest;
return interest;
}
public void withdraw(double amt) {
if (amt <= balance) {
balance -=
amt;
} else {
System.out.println("** Account balance is low **");
}
}
public void deposit(double amt) {
balance += amt;
}
@Override
public String toString() {
System.out.println("\nAccount ID:"
+ id);
System.out.printf("Balance:$%.2f\n"
, balance);
System.out.printf("Interest Rate:
%.3f\n" , (annualInterestRate/100));
System.out.println("Date Account
Created:" + new
SimpleDateFormat("dd/MM/yyyy").format(dateCreated));
return "";
}
}
======================================
=============================================
// TestAccount.java
public class TestAccount {
public static void main(String[] args) {
Account acc=new
Account(5544,45000);
acc.setAnnualInterestRate(3.6);
acc.getMonthlyInterest();
acc.withdraw(3700);
acc.deposit(2200);
System.out.println(acc);
}
}
=============================================
=============================================
Output:
=====================Could you plz rate me well.Thank You