Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Name : Kyle Blanchard
- // Due : 10/8/2014
- // Class : CSCI-401
- // Assignment : Account Class ~ Homework # 7
- // Contact : Kwblanchard@student.stcc.edu
- // package csci401;
- import java.util.Date;
- public class Account {
- private int id;
- private double balance;
- private double annualIntrestRate;
- private Date dateCreated;
- public Account() {
- }
- public Account(int id, double balance) {
- this.id = id;
- this.balance = balance;
- annualIntrestRate = 0;
- dateCreated = new Date();
- }
- public double getMonthlyIntrestRate() {
- return annualIntrestRate / 12.0;
- }
- public void withdraw(double withdrawel) {
- balance -= withdrawel;
- }
- public void deposit(double deposit) {
- balance += deposit;
- }
- public String toString() {
- return "Balance: " + balance + "\nMonthly Intrest Rate: "
- + getMonthlyIntrestRate() + "\nAccount Creation Date: "
- + dateCreated;
- }
- // Eclipse Generated Accessors and Mutators
- public int getId() {
- return id;
- }
- public double getBalance() {
- return balance;
- }
- public double getAnnualIntrestRate() {
- return annualIntrestRate;
- }
- public Date getDateCreated() {
- return dateCreated;
- }
- public void setId(int id) {
- this.id = id;
- }
- public void setBalance(double balance) {
- this.balance = balance;
- }
- public void setAnnualIntrestRate(double annualIntrestRate) {
- this.annualIntrestRate = annualIntrestRate;
- }
- // Test Program
- public static void main(String args[]) {
- Account account = new Account(1122, 20000);
- account.setAnnualIntrestRate(4.5);
- account.withdraw(2500);
- account.deposit(3000);
- System.out.println(account);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement