-
Notifications
You must be signed in to change notification settings - Fork 0
/
Account.java
78 lines (58 loc) · 1.53 KB
/
Account.java
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
66
67
68
69
70
71
72
73
74
75
76
77
78
package BankApplicationpack;
public abstract class Account implements BaseRate {
private String name;
private String sSn;
private double balance;
protected String accountNumber;
protected double rate;
private static int counter =10000 ;
public Account(String name , String ssN,double initDeposit)
{
this.name = name;
this.sSn = ssN;
balance = initDeposit;
this.accountNumber = setaccountNumber();
setRate();
}
public abstract void setRate();
private String setaccountNumber()
{
String last2SSN = sSn.substring(sSn.length()-2,sSn.length());
int uniqueID = counter ;
int randomNum =(int) (Math.random()*Math.pow(10,3));
return last2SSN + uniqueID + randomNum;
}
public void deposit(double amount)
{
balance = balance + amount;
System.out.println("Depositing ");
}
public void withdraw(double amount)
{
balance = balance - amount;
System.out.print("Withdrawing ... ");
}
public void transfer(String tranferaccno, double amount)
{
balance = balance - amount;
System.out.println("Transferring to " + tranferaccno);
}
public void showbalance()
{
System.out.println("Balance :" + balance);
}
public void compound()
{
double actualrateofInterest= balance * (rate/100) ;
System.out.println("Compound Interese :" + actualrateofInterest);
balance = balance+actualrateofInterest;
}
public void showinfo()
{
System.out.println(
"\nNAME :" + name + "\n" +
"ACCOUNT NUMBER :" + accountNumber +"\n" +
"AVAILABLE BALANCE :" + balance +"\n"
);
}
}