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; } }

Could someone help me draw a UML class diagram for this code? Thank you!

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

Linked Data A Geographic Perspective

Authors: Glen Hart, Catherine Dolbear

1st Edition

1000218910, 9781000218916

Students also viewed these Databases questions