forked from kaal-coder/hacktoberfest2023
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprogram_48.java
More file actions
106 lines (91 loc) · 2.62 KB
/
Copy pathprogram_48.java
File metadata and controls
106 lines (91 loc) · 2.62 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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
import java.util.Scanner;
class bank
{
public String Name = "dream bank";
public String IFSC = "dream123";
public void bankdetail()
{
System.out.println("Bank Name: " + Name + "Bank IFSC Code: " + IFSC);
}
// password
abstract void deposit();
abstract void withdraw();
abstract void checkbal();
}
class bankservice extends bank
{
private double bal = 5000;
private int pwd;
public double money;
public void deposit()
{
System.out.println("enter the password");
Scanner s = new Scanner(System.in);
pwd = s.nextInt();
if (pwd == 123)
{
System.out.println("enter deposit amount");
money = s.nextDouble();
bal = bal + money;
System.out.println("Deposit amount: " + money);
System.out.println("Total balance: " + bal);
} else {
System.out.println("Invalid password...");
}
}
public void withdraw() {
System.out.println("enter the password");
Scanner s = new Scanner(System.in);
pwd = s.nextInt();
if (pwd == 123)
{
System.out.println("enter withdrawn amount");
money = s.nextDouble();
bal = bal - money;
System.out.println("withdrawn money : " + money);
System.out.println("Total balance: " + bal);
} else
{
System.out.println("Invalid password...");
}
}
public void checkbal() {
System.out.println("enter password");
Scanner s = new Scanner(System.in);
pwd = s.nextInt();
if (pwd == 123) {
System.out.println("total balance " + bal);
} else {
System.out.println("incorrect password...");
}
}
}
class customer
{
public static void main(String[] args)
{
bankservice b = new bankservice();
b.bankdetail();
int ch;
System.out.println("1. deposit");
System.out.println("2. withdraw");
System.out.println("3. check balance");
System.out.println("enter your choice");
Scanner s2 = new Scanner(System.in);
ch = s2.nextInt();
switch (ch)
{
case 1:
b.deposit();
break;
case 2:
b.withdraw();
break;
case 3:
b.checkbal();
break;
default:
System.out.println("invalid choice");
}
}
}