Question: import java.util.Date; public class Assignment1 { public static void main(String[] args) { Account account = new Account(1122, 20000); account.setAnnualInterestRate(4.5); account.withdraw(2500); account.deposit(3000); System.out.println(Balance is +

import java.util.Date; public class Assignment1 {

public static void main(String[] args) { Account account = new Account(1122, 20000); account.setAnnualInterestRate(4.5);

account.withdraw(2500); account.deposit(3000); System.out.println("Balance is " + account.getBalance()); System.out.println("Monthly interest is " + account.getMonthlyInterest()); System.out.println("This account was created at " + account.getDateCreated()); } }

class Account { private int id; private double balance, annualInterestRate; private Date dateCreated; public Account(int id, double balance) { this.id = id; this.balance = balance; dateCreated = new Date(); } public Account() { this(0, 0); } public int getId() { return id; }

public void setId(int id) { this.id = id; }

public double getAnnualInterestRate() { return annualInterestRate; }

public void setBalance(double balance) { this.balance = balance; }

public String getDateCreated() { return dateCreated.toString(); } public double getMonthlyInterest() { return balance * annualInterestRate / 1200.0; } public double getBalance() { return balance; } public void deposit(double a) { balance += a; } public void withdraw(double i) { if(balance >= i) { balance -= i; } } public void setAnnualInterestRate(double d) { annualInterestRate = d; } }

1) What does this program do? Could you please describe it including the input (what it asks the user to input) and output (result of the code). (5-6 sentences)

2) Also, how would you test this program to make sure it works properly? Provide the output generated with the print commands pls.

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!