Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Date;
- public class Account {
- private int id;
- private double balance;
- private static double annualInterestRate;
- private Date dateCreated;
- public Account(int id, double balance) {
- this.id = id;
- this.balance = balance;
- dateCreated = new Date();
- }
- public Account() {
- this(0, 0);
- }
- public void setId(int id) {
- this.id = id;
- }
- public int getId() {
- return id;
- }
- public void setBalance(double balance) {
- this.balance = balance;
- }
- public double getBalance() {
- return balance;
- }
- public static void setAnnualInterestRate(double interestRate) {
- annualInterestRate = interestRate;
- }
- public static double getAnnualInterestRate() {
- return annualInterestRate;
- }
- public Date getDateCreated() {
- return dateCreated;
- }
- public static double getMonthlyInterestRate() {
- return (annualInterestRate / 12);
- }
- public void withdraw(double amount) {
- if (amount <= balance) {
- if (amount > 0) {
- balance -= amount;
- } else {
- System.out.println("Please enter a number greater than 0.");
- }
- } else {
- System.out.println("You do not have enough money!");
- }
- }
- public void deposit(double amount) {
- if (amount > 0) {
- balance += amount;
- } else {
- System.out.println("Please enter a number greater than 0.");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement