Skip to content

Commit babc846

Browse files
ATM.java
1 parent cf0886e commit babc846

1 file changed

Lines changed: 28 additions & 0 deletions

File tree

ATM.java

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
import java.util.*;
2+
3+
public class ATM {
4+
public static void main(String[] args) {
5+
Scanner sc = new Scanner(System.in);
6+
int balance = 5000;
7+
8+
while (true) {
9+
System.out.println("1.Withdraw 2.Deposit 3.Check Balance 4.Exit");
10+
int ch = sc.nextInt();
11+
12+
if (ch == 1) {
13+
System.out.print("Amount: ");
14+
int a = sc.nextInt();
15+
if (a <= balance) balance -= a;
16+
else System.out.println("Insufficient balance!");
17+
}
18+
else if (ch == 2) {
19+
System.out.print("Amount: ");
20+
balance += sc.nextInt();
21+
}
22+
else if (ch == 3) {
23+
System.out.println("Balance = " + balance);
24+
}
25+
else break;
26+
}
27+
}
28+
}

0 commit comments

Comments
 (0)