-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathatm.java
More file actions
67 lines (62 loc) · 2.36 KB
/
atm.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
import java.util.Scanner;
public class atm {
public static void main(String[] args) {
String username,password;
Scanner inp = new Scanner(System.in);
int right = 3;
int balance = 25000;
int select;
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) {
case 1:
int a;
System.out.println("how much do you want to deposit ?");
a = inp.nextInt();
System.out.println("New balance is:"+(balance+a));
break;
case 2:
int b;
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;
case 3:
System.out.println("Balance:"+balance);
break;
case 4:
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();
}
}