forked from Revnth/Hacktoberfest2022
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Bank.java
77 lines (77 loc) · 1.5 KB
/
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
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
import java.util.Scanner;
interface Bank
{
Scanner sc = new Scanner (System.in);
void getDetails ();
void calculateInterest ();
void getMAmount ();
}
class SBI implements Bank
{
String name;
double principal;
double period;
double interest;
double roi = 8.5;
public void getDetails ()
{
System.out.println ("Enter Name");
name = sc.nextLine();
System.out.println ("Enter Principal");
principal = sc.nextDouble();
System.out.println ("Enter Period");
period = sc.nextDouble();
}
public void calculateInterest ()
{
interest = (principal * period * roi)/100;
}
public void getMAmount ()
{
double mAmount = principal + interest;
System.out.println (name+" your Maturity Amount in SBI is Rs. "+mAmount+"\n");
}
}
class CanaraBank implements Bank
{
String name;
double principal;
double period;
double interest;
double roi = 8.5;
public void getDetails ()
{
System.out.println ("Enter Name");
name = sc.next();
System.out.println ("Enter Principal");
principal = sc.nextDouble();
System.out.println ("Enter Period");
period = sc.nextDouble();
}
public void calculateInterest ()
{
interest = (principal * period * roi)/100;
}
public void getMAmount ()
{
double mAmount = principal + interest;
System.out.println (name+" your Maturity Amount in Canara Bank is Rs. "+mAmount+"\n");
}
}
class BRun
{
public static void main (String args[])
{
Bank b;
SBI sb = new SBI ();
CanaraBank cb = new CanaraBank ();
b = sb;
b.getDetails ();
b.calculateInterest ();
b.getMAmount ();
b = cb;
b.getDetails ();
b.calculateInterest ();
b.getMAmount ();
}
}