Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

THE FOLLOWING IS MY CODE IN JAVA. WITH THE OUTPUT OF Balance: $500.0 Monthly Interest: 1.875 Date Created: Mon Jul 09 00:25:40 EDT 2018 I

THE FOLLOWING IS MY CODE IN JAVA. WITH THE OUTPUT OF

Balance: $500.0 Monthly Interest: 1.875 Date Created: Mon Jul 09 00:25:40 EDT 2018

I NEED IT TO DISPLAY THE OUTPUT OF

Balance is 20500.0 Monthly interest is 76.875 This account was created at Thu Oct 26 10:27:48 EDT 2017

public class Exercise_09_07 {
public static void main(String[] args) {
Account account = new Account(1122, 20000);
account.setAnnualInterestRate(4.5);
account.withdraw(2500.0);
account.deposit(3000.0);
System.out.println("Balance: $" + account.getBalance());
System.out.println("Monthly Interest: " + account.getMonthlyInterest());
System.out.println("Date Created: " + account.getDateCreated());
}
}
class Account {
private int id = 0;
private double balance = 0.0;
private static double annualInterestRate = 0.0;
private java.util.Date dateCreated;
public Account() {
dateCreated = new java.util.Date();
}
public Account(int id, double balace) {
this();
this.id = id;
this.balance = balance;
}
public int getId() {
return this.id;
}
public double getBalance() {
return this.balance;
}
public double getAnnualInterestRate() {
return annualInterestRate;
}
public String getDateCreated() {
return this.dateCreated.toString();
}
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 double getMonthlyInterestRate() {
return (annualInterestRate / 100) / 12 ;
}
public double getMonthlyInterest() {
return balance * getMonthlyInterestRate();
}
public void withdraw(double 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

Main Memory Database Systems

Authors: Frans Faerber, Alfons Kemper, Per-Åke Alfons

1st Edition

1680833243, 978-1680833249

More Books

Students also viewed these Databases questions