- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathatm.java
More file actions
Latest commit
67 lines (62 loc) · 2.36 KB
/
Copy pathatm.java
File metadata and controls
67 lines (62 loc) · 2.36 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
importjava.util.Scanner;
publicclassatm {
publicstaticvoidmain(String[] args) {
Stringusername,password;
Scannerinp = newScanner(System.in);
intright = 3;
intbalance = 25000;
intselect;
while(right>0){
System.out.println("ID:");
username = inp.nextLine();
System.out.println("password:");
password = inp.nextLine();
// username : java --- password : java123
if(username.equals("java") && (password.equals("java123"))){
System.out.println("select your operation");
System.out.println( "1-Deposit\n" +
"2-Withdrawal\n" +
"3-balance inquiry\n" +
"4-Exit");
System.out.println("----------------");
select = inp.nextInt();
switch (select) {
case1:
inta;
System.out.println("how much do you want to deposit ?");
a = inp.nextInt();
System.out.println("New balance is:"+(balance+a));
break;
case2:
intb;
System.out.println("how much do you want to withdraw money?");
b = inp.nextInt();
if(b>balance){
System.out.println("invalid value !! Your balance is :"+ balance);
}else{
System.out.println("new balance is :"+ (balance-b));
}
break;
case3:
System.out.println("Balance:"+balance);
break;
case4:
System.out.println("Exiting!!");
break;
default:
break;
}
break;
}else{
right--;
if(right == 0){
System.out.println("your account is blocked!!");
break;
}else{
System.out.println(right+" right left");
}
}
}
inp.close();
}
}