Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

\\\\So heres my code: import java.util.Date; public class Account { /** account

ID: 3625973 • Letter: #

Question

\So heres my code:


import java.util.Date;


public class Account {
/** account id */
private int id;

/** account balance */
private double balance;

/** account annual interest rate */
private double annualInterestRate;

/** date account was created */
private Date dateCreated;

/**
* No args constructors, initialize to defaults
* */
public Account() {
//set to defaults
id = 0;

balance = 0;

annualInterestRate = 0;

//date created initialized to current date and time
dateCreated = new Date( System.currentTimeMillis( ) );
}

/**
* Deposits money into account
* */
public void deposit(double ammount){
balance += ammount;
}

/**
* withdraw money from account
* */
public void withdraw( double ammount){
balance -= ammount;
}


/**
* compute monthly interest rate
* */
public double getMonthlyInterestRate( ){
return annualInterestRate / 12;
}

//
//accessor & muttator methods for id, balance, interest rate
//



public int getId() {
return id;
}

public Date getDateCreated() {
return dateCreated;
}

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 void setAnnualInterestRate(double annualInterestRate) {
this.annualInterestRate = annualInterestRate;
}
}

\Here is my test case

public class AccountTest {

/**
* @param args
*/
public static void main(String[] args) {

//create account object
Account account = new Account();


//set id to 1122
account.setId( 1122 );

//set balance $20.000
account.setBalance( 20000 );

//set interest rate 4.5%
account.setAnnualInterestRate( 0.045 );

//withdraw $2.500
account.withdraw( 2500 );

//deposit $3.000
account.deposit( 3000 );

//print balance
System.out.println("Balance: " + account.getBalance( ) );

//print monthly interest rate
System.out.println("Monthly Interest Rate: " + account.getMonthlyInterestRate( ) * 100 + "%" );

//print account create date
System.out.println("Account Create Date: " + account.getDateCreated( ).toString( ));

}

}

Im stuck modifying my test case to do this:
Create an array of 10 reference variables of the type Account. Create a test program that will randomly populate 10 instances of the class, i.e., will create 10 objects of type account with each object assigned to one of the reference variables. Withdraw a random amount from each object, deposit a random amount to each account and then print the balance, the monthly interest rate and the date the account was created down to the milliseconds.

Explanation / Answer

import java.util.Date; import java.io.*; import java.lang.*; class Account { int id; /** account id */ double balance; /** account balance */ double annualInterestRate; /** account annual interest rate */ Date dateCreated; /** date account was created */ public Account() { id = 0; //set to defaults balance = 0; annualInterestRate = 0; dateCreated = new Date( System.currentTimeMillis( ) ); //date created initialized to current date and time } public void deposit(double ammount) /*** Deposits money into account* */ { balance += ammount; } public void withdraw( double ammount) /*** withdraw money from account* */ { balance -= ammount; } public double getMonthlyInterestRate( ) /*** compute monthly interest rate* */ { return annualInterestRate / 12; } //accessor & muttator methods for id, balance, interest rate public int getId() { return id; } public Date getDateCreated() { return dateCreated; } 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 void setAnnualInterestRate(double annualInterestRate) { this.annualInterestRate = annualInterestRate; } } public class AccountTest { public static void main(String args[]) /*** @param args*/ { Account obj = new Account(); //create account object obj.setId( 1122 ); //set id to 1122 obj.setBalance( 20000 ); //set balance $20.000 obj.setAnnualInterestRate( 0.045 ); //set interest rate 4.5% obj.withdraw( 2500 ); //withdraw $2.500 obj.deposit( 3000 ); //deposit $3.000 System.out.println("Balance: " + obj.getBalance( ) ); //print balance System.out.println("Monthly Interest Rate: " + obj.getMonthlyInterestRate( ) * 100 + "%" ); //print monthly interest rate System.out.println("Account Create Date: " + obj.getDateCreated( ).toString( )); //print account create date } } //run it on jdk1.6