-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathATM.java
More file actions
62 lines (54 loc) · 2.15 KB
/
ATM.java
File metadata and controls
62 lines (54 loc) · 2.15 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
import java.util.*;
public class ATM
{
public static void main(String args[])
{
int balance = 10000, withdraw, deposit;
Scanner sc = new Scanner(System.in);
while(true)
{
System.out.println("\n\t\t------------------------");
System.out.println("\t\tAutomated Teller Machine");
System.out.println("\t\t------------------------\n");
System.out.println("Choose 1 for Withdraw");
System.out.println("Choose 2 for Deposit");
System.out.println("Choose 3 for Check Balance");
System.out.println("Choose 4 for EXIT");
System.out.print("\nChoose the operation you want to perform: ");
int choice = sc.nextInt();
switch(choice)
{
case 1:
System.out.print("Enter money to be withdrawn: ");
withdraw = sc.nextInt();
if(balance >= withdraw)
{
balance = balance - withdraw;
System.out.println("Please collect your money");
}
else
{
System.out.println("Insufficient Balance");
}
System.out.println("");
break;
case 2:
System.out.print("Enter money to be deposited: ");
deposit = sc.nextInt();
balance = balance + deposit;
System.out.println("Your Money has been successfully depsited ");
System.out.println("");
break;
case 3:
System.out.println("Balance : "+balance);
System.out.println("");
break;
case 4:
System.exit(0);
default:
System.out.println("Invalid Input");
System.out.println("");
}
}
}
}