-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathATM_interface.java
76 lines (71 loc) · 2.66 KB
/
ATM_interface.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
74
75
76
package OasisInfobyte;
import java.util.Scanner;
public class ATMInterface
{
public static void main(String args[]){
int Balance = 100000, Withdraw, Deposit;
Scanner sc = new Scanner(System.in);
int pin=1234;
System.out.println("Enter Pin : ");
int pass=sc.nextInt();
int i=1;
if(pass!=pin){
while(true){
i++;
System.out.println("Wrong Pin");
System.out.println("Re-enter pin (Attempts Remaining :- "+i+") : ");
pass=sc.nextInt();
if(pass==pin)
{
break;
}
if(i==3){
System.out.println("You have exceeded your trials,Retry After some time !");
System.exit(0);
}
}
}
if(pass==pin)
{
System.out.println("<------Welcome ------>");
System.out.println("Choose your choice");
while(true)
{
System.out.println("1] Balance Check");
System.out.println("2] Withdraw money");
System.out.println("3] Deposit money");
System.out.println("4] Exit");
int choice = sc.nextInt();
switch(choice)
{
case 1:
System.out.println("Balance is :- "+Balance);
System.out.println("");
break;
case 2:
System.out.println("Enter Withdrawal amount : ");
Withdraw=sc.nextInt();
if(Withdraw>Balance||Balance==0)
{
System.out.printf("Sorry you have insufficient balance!!\n");
break;
}
System.out.println("Collect your amount");
Balance=Balance-Withdraw;
System.out.println("");
break;
case 3:
System.out.print("Enter amount to be deposited: ");
Deposit = sc.nextInt();
Balance = Balance + Deposit;
System.out.println("Your Money has been deposited successfully");
System.out.println(" ");
break;
case 4:
System.out.println("We are Happy to Service you... Thank you");
System.exit(0);
}
}
}
}
}