-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathATM.java
More file actions
28 lines (25 loc) · 820 Bytes
/
ATM.java
File metadata and controls
28 lines (25 loc) · 820 Bytes
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
import java.util.*;
public class ATM {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int balance = 5000;
while (true) {
System.out.println("1.Withdraw 2.Deposit 3.Check Balance 4.Exit");
int ch = sc.nextInt();
if (ch == 1) {
System.out.print("Amount: ");
int a = sc.nextInt();
if (a <= balance) balance -= a;
else System.out.println("Insufficient balance!");
}
else if (ch == 2) {
System.out.print("Amount: ");
balance += sc.nextInt();
}
else if (ch == 3) {
System.out.println("Balance = " + balance);
}
else break;
}
}
}