-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccount.java
More file actions
65 lines (63 loc) · 1.74 KB
/
Account.java
File metadata and controls
65 lines (63 loc) · 1.74 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
/*
* Click nbfs://nbhost/SystemFileSystem/Templates/Licenses/license-default.txt to change this license
* Click nbfs://nbhost/SystemFileSystem/Templates/Classes/Class.java to edit this template
*/
package sheet5;
/**
*
* @author 20100
*/
import java.util.Scanner;
public class Account {
private int id;
private double balance;
private static double annualInterestRate;
private Date dateCreated;
Account(){
}
Account(int id,double initialBalance){
this.id=id;
this.balance=initialBalance;
}
public void setID(int id){
this.id=id;
}
public void setBalance(double balance){
this.balance=balance;
}
public static void setAnnualInterestRate(double AIR){
annualInterestRate=AIR;
}
public int getID(){
return this.id;
}
public double getBalance(){
return this.balance;
}
public static double getAnnualInterestRate(){
return annualInterestRate;
}
public String getDateCreated(){
return this.dateCreated.date;
}
public static double getMonthlyInterestRate(){
return annualInterestRate/12;
}
public double getMonthlyInterest(){
return this.balance*getMonthlyInterestRate();
}
public void withdraw(double amount){
this.balance-=amount;
}
public void deposit(double amount){
this.balance+=amount;
}
public class Date{
Scanner input=new Scanner(System.in);
String date;
Date(){
System.out.println("Enter the day,month and year (for today'the day when this account was created')respectively:");
date=input.nextInt()+"/"+input.nextInt()+"/"+input.nextInt();
}
}
}