The world’s Largest Sharp Brain Virtual Experts Marketplace Just a click Away
Levels Tought:
Elementary,Middle School,High School,College,University,PHD
| Teaching Since: | Apr 2017 |
| Last Sign in: | 138 Weeks Ago |
| Questions Answered: | 4870 |
| Tutorials Posted: | 4863 |
MBA IT, Mater in Science and Technology
Devry
Jul-1996 - Jul-2000
Professor
Devry University
Mar-2010 - Oct-2016
0133593517.pdf
public class Exercise09_07 {
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;
private double annualInterestRate;
private java.util.Date dateCreated;
Account()
{
this.id = 0;
this.balance = 0;
this.annualInterestRate = 0;
this.dateCreated = new java.util.Date();
}
public Account(int id, double balance) {
super();
this.id = id;
this.balance = balance;
this.dateCreated = new java.util.Date();
}
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public double getBalance() {
return balance;
}
public void setBalance(double balance) {
this.balance = balance;
}
public double getAnnualInterestRate() {
return annualInterestRate;
}
public void setAnnualInterestRate(double annualInterestRate) {
this.annualInterestRate = annualInterestRate/100;
}
public java.util.Date getDateCreated() {
return dateCreated;
}
public double getMonthlyInterestRate()
{
return this.annualInterestRate / 12;
}
public double getMonthlyInterest(){
return getMonthlyInterestRate()*this.balance;
}
public void withdraw(double amount)
{
this.balance = this.balance - amount;
}
public void deposit(double amount)
{
this.balance = this.balance + amount;
}
public static void main(String[] args) {
CheckingAccount checking = new CheckingAccount(1, 35);
SavingsAccount savings = new SavingsAccount(2, 25);
checking.withdraw(10);
savings.withdraw(10);
System.out.println(checking.getBalance());
System.out.println(savings.getBalance());
}
}