Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- *
- * Nate Wheeler
- * HW 8
- * Compsci 220
- * nrwheeler@student.stcc.edu
- *
- */
- import java.util.Date;
- public class Account {
- private int id;
- private double balance;
- private static double annualInterestRate;
- private Date dateCreated;
- public Account() {
- this.id = 0;
- this.balance = 0;
- this.annualInterestRate = 0;
- this.dateCreated = new Date();
- }
- public Account(int a, double b) {
- this.id = a;
- this.balance = b;
- this.annualInterestRate = 0;
- this.dateCreated = new Date();
- }
- public int getId() {
- return id;
- }
- public void setId(int id) {
- this.id = id;
- }
- public double getBalance() {
- return balance;
- }
- public void setBalance(double balance) {
- this.balance = balance;
- }
- public static double getAnnualInterestRate() {
- return annualInterestRate;
- }
- public static void setAnnualInterestRate(double annualInterestRate) {
- Account.annualInterestRate = annualInterestRate;
- }
- public Date getDateCreated() {
- return dateCreated;
- }
- public double getMonthlyInterestRate() {
- double interest = this.balance * Account.annualInterestRate;
- return interest;
- }
- public void withdraw(double d) {
- balance -= d;
- }
- public void deposit(double d) {
- balance += d;
- }
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Account bank = new Account(1122, 20000);
- Account.setAnnualInterestRate(4.5);
- bank.withdraw(2500);
- bank.deposit(3000);
- System.out.println("balance: " + bank.getBalance() + "\nmonthly Interest: " + bank.getMonthlyInterestRate()
- + "\ndate created: " + bank.getDateCreated());
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement