Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

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_2

Step: 3

blur-text-image_3

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

Professional Microsoft SQL Server 2014 Integration Services

Authors: Brian Knight, Devin Knight

1st Edition

1118850904, 9781118850909

More Books

Students also viewed these Databases questions

Question

when formatting a cell as an absoluye refrenece or addres, you...

Answered: 1 week ago

Question

3. What changes should I be making?

Answered: 1 week ago

Question

2. Why?

Answered: 1 week ago