-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAtm.java
More file actions
63 lines (55 loc) · 2.42 KB
/
Atm.java
File metadata and controls
63 lines (55 loc) · 2.42 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
import java.util.Scanner;
public class Atm {
public static void main(String[] args) {
String username,password;
int right=3;
int balance=6500;
int select;
Scanner scn =new Scanner(System.in);
while ( right>0) {
System.out.println("please enter your username: ");
username=scn.nextLine();
System.out.println("Please enter your password: ");
password= scn.nextLine();
if (username.equals("patika") && password.equals("dev123")) {
System.out.println("Hi! Welcome to Kodluyoruz Bank!");
do {
System.out.println("1-Para yatırma \n 2-Para Çekme \n 3-Bakiye Sorgulama \n 4-Çıkış yapma");
System.out.println("Please select your choice");
select = scn.nextInt();
switch (select) {
case 1:
System.out.println("enter the amount of money");
int price = scn.nextInt();
balance += price;
System.out.println("New balance: " + balance);
break;
case 2:
System.out.println("Enter the amount of money");
price = scn.nextInt();
if (balance < price) {
System.out.println("insufficient balance");
} else {
balance -= price;
System.out.println("Balance: " + balance);
}
break;
case 3:
System.out.println("Balance: " + balance);
break;
}
} while (select != 4) ;
System.out.println("See you again.");
break;
} else {
right--;
System.out.println("Incorrect username or password. Try again.");
if (right == 0) {
System.out.println("Your account has been blocked, please contact the bank");
} else {
System.out.println("Your remaining right:" + right);
}
}
}
}
}