micher43

E3.4 (BankAccount Class)

Oct 1st, 2014
180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.78 KB | None | 0 0
  1. public class BankAccount {
  2.    
  3.     private double balance;
  4.    
  5.     /**
  6.      * constructor for initial balance of balance
  7.      */
  8.     public BankAccount(double initialValue){
  9.         balance = initialValue;
  10.     }
  11.    
  12.     /**
  13.      * deposit some amount into the account
  14.      * @param amount
  15.      */
  16.     public void Deposit(double amount){
  17.         balance = balance + amount;
  18.     }
  19.    
  20.     /**
  21.      * withdraw some amount from the account
  22.      * @param amount
  23.      */
  24.     public void Withdraw(double amount){
  25.         balance = balance - amount;
  26.     }
  27.    
  28.     /**
  29.      * get the balance so you can print it or whatever
  30.      * @return
  31.      */
  32.     public double GetBalance(){
  33.         return balance;
  34.     }
  35.    
  36.     /**
  37.      * rate of simple interest in bank account
  38.      * @param rate
  39.      */
  40.     public void addInterest(double rate){
  41.         balance = (balance * (rate/100)) + balance;
  42.     }
  43.    
  44. }
Add Comment
Please, Sign In to add comment