title: Object and Classes: Finding balance ,annual interest rate, monthly interest rate, withdrawing, depositing
body: <p>Instructions: Design a class named Account that contains: </p>
  
  <p>A private int data field named id for the account ( default 0). </p>
  
  <ol>
  <li>A private double data field named balance for the account ( default 0). </li>
  <li>A private constant double data field named annualInterestRate that stores the current interest rate of 12%.  Assume all accounts have the same interest rate. </li>
  <li>A private Date data field named dateCreated that stores the date when the account was created. </li>
  <li>A no-arg constructor that creates a default account.   </li>
  <li>A constructor that creates an account with the specified id and initial balance.  </li>
  <li>The accessor (setter) and mutator (getter) methods for id, balance, and annualInterestRate. </li>
  <li>The accessor method for dateCreated. </li>
  <li>A method named getMonthlyInterestRate() that returns the monthly interest rate in as a percentage.  For example it returns 1, not .01, for a 1% monthly rate. </li>
  <li>A method named getMonthlyInterest() that returns the monthly interest.  </li>
  <li>A method named withdraw that withdraws a specified amount from the account.  </li>
  <li>A method named deposit that deposits a specified amount to the account. </li>
  </ol>
  
  <p>Create a project file in Bluej and implement the class. ( Hint: The method getMonthlyInterest() is to return monthly interest, not the interest rate. Monthly interest is balance * monthlyInterestRate. monthlyInterestRate is annualInterestRate /1200. </p>
  
  <p>Test the program using BlueJ.  You should test each of the methods making sure that they are working properly.  </p>
  
  <p>Write a second class called AccountTester which contains the main method.  The account tester should do the following in this order:</p>
  
  <ol>
  <li>Create an account object</li>
  <li>Display the account balance</li>
  <li>Display the annualInterestRate</li>
  <li>Deposit $150</li>
  <li>Display the account balance</li>
  <li>Withdraw $50</li>
  <li>Display the account balance</li>
  <li>Deposits the monthly interest</li>
  <li>Display the account balance</li>
  </ol>
  
  <p>Here is my following code. I have errors I am just not sure how to fix them. Any help/tips would be appreciated</p>
  
  <pre><code>import java.util.Scanner;
  import java.util.Date;
  
  public class Account
  {
      private int id = 0;
      private double balance = 0;
      final private double annualinterestrate = 0.12;
      Date dateCreated;
  
      public Account()
      {
  
      }
  
      public Account(int aId, double aBalance, double annualInterestRate)
      {
          id = aId;
          balance = aBalance;
          annualInterestRate = annualInterestRate;
          dateCreated = new Date();
      }
  
      public void setID (int aId)
      {
          id = aId;
      }
  
      public int getID()
      {
          return id;
      }
  
      public void setBalance (double aBalance)
      {
          balance = aBalance;
      }
  
      public double getbalance()
      {
          return balance;
      }
  
      public void setAnnualInterestRate (double aannualInterestRate)
      {
          annualInterestRate = aannualInterestRate;
      }
  
      public double getAnnualInterestRate()
      {
          return annualInterestRate;
      }
  
      public Date getDateCreated()
      {
          return dateCreated;
      }
  
      public double getMonthlyInterestRate()
      {
          return annualInterestRate / 12;
      }
  
      public void withdraw(double amount)
      {
          balance -= amount;
      }
  
      public void deposit(double amount)
      {
          balance += amount;
      }
  }
  </code></pre>
  
  <p>Then here is the second class code which contains the main method:</p>
  
  <pre><code>public class AccountTester
  {
  
      public static void main(String[] args)
      {
          Account account = new Account(1857, 5000, 0.12);
  
          account.setID(1857);
          account.setBalance(5000);
          account.setAnnualInterestRate(0.12);
  
  
  
          System.out.println ("Account number: \n"+ +account.getID());
          System.out.println ("The account balance is: $ \n" + +account.getbalance());
          System.out.println("The Annual Interest Rate is: $ \n" + account.getannualInteresrRate());
          account.deposit(150);
          System.out.println("The account balance is: $ \n" +account.getbalance());
          account.withdraw(50);
          System.out.println("The account balance is: $ \n" +account.getbalance());
          System.out.println ("The monthly interest earned is: $ \n" + +account.getbalance() *    account.annualInterestRate());
          System.out.println ("The account was created on: \n" + +account.getdateCreated());
  
      }
  }
  </code></pre>