Class Account


public class Account extends Object
Dealing with account balances and interest calculations.
  • Constructor Details

    • Account

      public Account()
      Create a new account having a balance of 0.
    • Account

      public Account(double balance)
      Create a new account of given initial balance.
      balance - The account's initial balance.
  • Method Details

    • getBalance

      public double getBalance()
      The account's current balance.
    • setBalance

      public void setBalance(double balance)
      Setting a (possibly) new balance.
      balance - The desired new balance value. If greater than 10000 a warning message is being issued and the accounts current value will be retained.
    • setAssetInterestRate

      public static void setAssetInterestRate(double assetInterestRate)
      Setting the interest rate common to all accounts. This one will be applied to positive balances only. For handling negative balances see {setDebtInterestRate(double).
      assetInterestRate - The desired (global) interest rate.
    • getAssetInterestRate

      public static double getAssetInterestRate()
      The current global interest rate
    • getDebtInterestRate

      public static double getDebtInterestRate()
      The debt interest rate value.
    • setDebtInterestRate

      public static void setDebtInterestRate(double debtInterestRate)
      This interest rate will be applied to negative balances. In contrast {setAssetInterestRate(double) will handle positive balance values.
      debtInterestRate - The debt interest rate's value.
    • applyInterest

      public void applyInterest()

      Convenience method to {applyInterest(int)}: Adding one year's interest to the current balance according to:

      \[ balance_{1} = balance (1 + {interestRate\over 100}) \]
    • applyInterest

      public void applyInterest(int years)

      Adding the accumulated interest of a given number of years to the current balance according to:

      \[ balance_{years} = balance\ {\left(1 + {interestRate\over 100}\right)}^{years} \]

      Positive balances will receive the value of setAssetInterestRate(double) whereas calculation of negative balances will be based on {setDebtInterestRate(double).

      years - the given time period.
    • getYearlyInterest

      public double getYearlyInterest()
      Calculate the expected annual interest without changing the account's balance.
      Annual interest to be expected