-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathConsoleATM.java
More file actions
67 lines (58 loc) · 1.51 KB
/
ConsoleATM.java
File metadata and controls
67 lines (58 loc) · 1.51 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.*;
public class ConsoleATM {
public static void main(String[] args) {
Scanner sc=new Scanner (System.in);
System.out.println("Welcome to ATM");
System.out.println("Enter the phonenumber");
Long PhoneNumber =sc.nextLong();
System.out.println("Enter the pin");
int pass = sc.nextInt();
int balance=1000;
int rebalance=0;
Long OgPhoneNumber=12L;
int Ogpass=2345;
if((OgPhoneNumber==PhoneNumber)&&(Ogpass==pass )) {
System.out.println("Enter 0 - Deposit"+"");
System.out.println("Enter 1 - Withdraw money"+"");
System.out.println("Enter 2 - Check balance"+"");
System.out.println("Enter 3 - Exit"+"");
int a=sc.nextInt();
switch(a) {
case 0:{
System.out.println("Enter amount you deposit");
int add=sc.nextInt();
rebalance=balance+add;
System.out.println("Amount added to account:"+add);
System.out.println("Current balance:"+rebalance );
break;
}
case 1:
{
System.out.println("Enter amount you withdraw");
int with=sc.nextInt();
if(with<=balance) {
rebalance=balance-with;
System.out.println("Amount withdrawed account:"+with);
System.out.println("Current balance:"+rebalance );}
else {
System.out.println("insuffficient balance");
}
break;
}
case 2:
{
System.out.println("Current balance:"+ rebalance );
break;
}
case 3:
{
System.out.println("Thank you");
break;
}
}
}
else {
System.out.println("Wrong credintials,Try Again");
}
}
}