-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbank.java
47 lines (47 loc) · 816 Bytes
/
bank.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
import java.io.*;
class bankacct
{
private double bal;
bankacct(double b)
{
bal=b;
}
void contact(double r) throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter password");
String passwrd=br.readLine();
if(passwrd.equals("xyz123"))
{
Interest in=new Interest(r);
in.calculateInterest();
}
else
{
System.out.println("sorry");
return;
}
}
private class Interest
{
private double rate;
Interest(double r)
{
rate=r;
}
void calculateInterest()
{
double interest=bal*rate/100;
bal +=interest;
System.out.println("update balance="+bal);
}
}
}
class bank
{
public static void main(String[] args) throws IOException
{
bankacct account=new bankacct(10000);
account.contact(9.5);
}
}