-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAccountnew.java
More file actions
79 lines (72 loc) · 1.76 KB
/
Copy pathAccountnew.java
File metadata and controls
79 lines (72 loc) · 1.76 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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
import java.text.NumberFormat;
public class Accountnew
{
private String owner;
private static int accountNo=12345;
public int accNo;
protected float balance;
private double interest=0.05;
protected String password;
public Accountnew()
{
accountNo++;
accNo=accountNo;
balance=0;
}
public Accountnew(String own,float bal,String pass)
{
owner=own;
accountNo++;
accNo=accountNo;
balance=bal;
password=pass;
}
public void setOwner(String own)
{
owner=own;
}
public int getAccountnewNo()
{
return accNo;
}
public String getOwner()
{
return owner;
}
public float getBalance()
{
return balance;
}
public void deposit(float dep,String pass1)
{
if ((password==pass1) && (dep>0))
{
System.out.println("Login Sucessful");
balance+=dep;
System.out.println("Amount "+dep +" deposited to Accountnew Number : "+accNo+"\n");
}
else
System.out.println("Negative values cannot be deposited or Check Password\n");
}
/*else
System.out.println("Please Enter the Correct Password Cannot Deposit");*/
public void withdrawal(float wdraw,String pass1)
{
if (password==pass1 && (balance-wdraw>0))
{System.out.println("Login Sucessful");
balance-=wdraw;
System.out.println("Amount "+wdraw +" withdrawn from Accountnew Number : "+accNo+"\n");
}
else
System.out.println("Balance is limited to withdraw or check password\n");
}
/*else
System.out.println("Please Enter the Correct Password Cannot withdraw");*/
public String toString()
{
NumberFormat formatter = NumberFormat.getCurrencyInstance ();
String toScreen ;
toScreen = "\n" + accNo + " :\t" + formatter.format (balance) +"\n";
return toScreen;
}
}