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: | 103 Weeks Ago, 3 Days 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());
 }
}
Â