Advertisement
Guest User

nigger

a guest
Mar 6th, 2015
202
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.34 KB | None | 0 0
  1. import java.util.Date;
  2.  
  3. public class Account {
  4.  
  5.     private int id;
  6.     private double balance;
  7.     private static double annualInterestRate;
  8.     private Date dateCreated;
  9.    
  10.     public Account(int id, double balance) {
  11.         this.id = id;
  12.         this.balance = balance;
  13.         dateCreated = new Date();
  14.     }
  15.    
  16.     public Account() {
  17.         this(0, 0);
  18.     }
  19.    
  20.     public void setId(int id) {
  21.         this.id = id;
  22.     }
  23.    
  24.     public int getId() {
  25.         return id;
  26.     }
  27.    
  28.     public void setBalance(double balance) {
  29.         this.balance = balance;
  30.     }
  31.    
  32.     public double getBalance() {
  33.         return balance;
  34.     }
  35.    
  36.     public static void setAnnualInterestRate(double interestRate) {
  37.         annualInterestRate = interestRate;
  38.     }
  39.    
  40.     public static double getAnnualInterestRate() {
  41.         return annualInterestRate;
  42.     }
  43.    
  44.     public Date getDateCreated() {
  45.         return dateCreated;
  46.     }
  47.    
  48.     public static double getMonthlyInterestRate() {
  49.         return (annualInterestRate / 12);
  50.     }
  51.    
  52.     public void withdraw(double amount) {
  53.         if (amount <= balance) {
  54.             if (amount > 0) {
  55.                 balance -= amount;
  56.             } else {
  57.                 System.out.println("Please enter a number greater than 0.");
  58.             }
  59.         } else {
  60.             System.out.println("You do not have enough money!");
  61.         }
  62.     }
  63.    
  64.     public void deposit(double amount) {
  65.         if (amount > 0) {
  66.             balance += amount;
  67.         } else {
  68.             System.out.println("Please enter a number greater than 0.");
  69.         }
  70.     }
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement