-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTask3
73 lines (70 loc) · 2.61 KB
/
Task3
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 Main {
public static void main(String[] args) {
Scanner s= new Scanner(System.in);
operation o= new operation();
int op;
System.out.println("INDIAN BANK ATM");
op=0;
while (op != 4){
System.out.println("\n1. check balance");
System.out.println("2. deposit money");
System.out.println("3. withdraw money");
System.out.println("4.exit");
System.out.println("\nCHOOSE ONE OPTION");
op = s.nextInt();
if (op ==1){
o.checkbalance();
}
else if (op ==2){
o.deposit();
}
else if (op==3){
o.withdraw();
}
else if (op==4){
System.out.println("\nTHANKS FOR VISITING");
}
else{
System.out.println("INVALID INPUT");
System.out.println("TRY CHOOSING NUMBERS SUCH AS 1,2,3,4");
}
}
}
}
class operation{
int bm=0;
Scanner s= new Scanner(System.in);
int dm,wm;
public void checkbalance(){
System.out.println("CURRENT BALANCE : " +bm);
}
public void deposit(){
System.out.println("ENTER AMOUNT TO DEPOSIT: ");
dm = s.nextInt();
if (dm >=0){
bm = bm+dm;
System.out.println(" SUCCESFUL");
System.out.println("CLOSING BALANCE: " +bm);
}
else{
System.out.println("FAILED");
System.out.println("TRY AGAIN ");
}
}
public void withdraw(){
System.out.println("ENTER AMOUNT TO WITHDRAW: ");
wm = s.nextInt();
if (wm <= bm){
bm= bm-wm;
System.out.println("SUCCESFUL");
System.out.println("CLOSING BALANCE: " +bm);
}
else {
System.out.println("FAILED");
System.out.println(" INSUFFICIENT BALANCE");
System.out.println("YOUR BALANCE IS :" +bm);
System.out.println("TRY AGAIN ");
}
}
}