forked from kunalbandale/Java-Programs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Banking.java
73 lines (53 loc) · 1.76 KB
/
Banking.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
import java.util.Scanner;
public class Banking {
int credit , debit;
int total = 50000;
void cashWithDraw(int amount) {
if (amount >= 10000) {
System.out.println("Limit Exceeded! Cannot withdraw " + amount);
} else {
total = total - amount;
System.out.println("Amout debited " + amount);
}
}
void Deposit(int amount) {
if (amount >= 50000) {
System.out.println("Amout cannot be debited");
} else {
total = total + amount;
System.out.println("Amout credit " + amount);
}
}
void checkBalance() {
System.out.println("Your account balance is " + total);
}
void exit() {
}
public static void main(String[] args) {
Banking b = new Banking();
Scanner sc = new Scanner(System.in);
while (true) {
System.out.println("Enter Option!!");
int option = sc.nextInt();
switch (option) {
case 1:
System.out.println("Enter amount you want to withdraw");
int amount = sc.nextInt();
b.cashWithDraw(amount);
break;
case 2:
System.out.println("Enter amount you want to withdraw");
int amount1 = sc.nextInt();
b.Deposit(amount1);
break;
case 3:
b.checkBalance();
break;
case 4:
b.exit();
default:
System.out.println("Please Enter Correct Option");
}
}
}
}