Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Make the following changes to your Account.java class: 1) Update the getDateCreated method to return a copy of the reference for the dateCreated field. SAMPLE

Make the following changes to your Account.java class:

1) Update the "getDateCreated" method to return a copy of the reference for the dateCreated field.

SAMPLE RUN:

BEFORE THE UPDATES, USING THE ATTACHED DRIVER:

Account balance: -29500.0

Account monthly interest rate: 0.375

Account date created: Wed Dec 31 19:00:00 EST 1969

image text in transcribed

public class Driver{ public static void main( String[] args ){ Account account = new Account( 1122, 2000 ); account.setAnnualInterestRate( 4.5 ); account.withdraw( 2500 ); account.deposit( 3000 ); System.out.println( "Account balance: " + account.getBalance( ) ); System.out.println( "Account monthly interest rate: " + account.getMonthlyInterestRate( ) ); System.out.println( "Account date created: " + account.getDateCreated( ) ); } } 

image text in transcribed

import java.util.Date; public class Account { // data fields private int id; private double balance; private double annualInterestRate; private Date dateCreated; // constructors public Account() { dateCreated = new Date(); } public Account(int id, double balance) { this.id = id; this.balance = balance; this.dateCreated = new Date(); } // accessors public int getId() { return this.id; } public double getBalance() { return this.balance; } public double getAnnualInterestRate() { return this.annualInterestRate; } public Date getDateCreated() { return dateCreated; } public double getMonthlyInterestRate() { return annualInterestRate / 12; } // mutators public void setId(int id) { this.id = id; } public void setBalance(double balance) { this.balance = balance; } public void setAnnualInterestRate(double annualInterestRate) { this.annualInterestRate = annualInterestRate; } public void withdraw(double amount) { if(this.balance > amount){ this.balance -= amount; } } public void deposit(double amount) { this.balance += amount; } } 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Expert Systems Applications 19th International Conference Dexa 2008 Turin Italy September 2008 Proceedings Lncs 5181

Authors: Sourav S. Bhowmick ,Josef Kung ,Roland Wagner

2008th Edition

3540856536, 978-3540856535

Students also viewed these Databases questions

Question

Activity Predecessor(s) START START START Duration 11 12 18 15

Answered: 1 week ago