-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathATMStimulator.java
More file actions
65 lines (43 loc) · 1.85 KB
/
ATMStimulator.java
File metadata and controls
65 lines (43 loc) · 1.85 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
import java.util.Scanner;
public class ATMStimulator {
public static void main(String[]args) {
Scanner input = new Scanner (System.in);
double balance = 1000;
double deposit = 0;
double withdraw = 0;
int choice = 0;
while(true){
System.out.println("\nATM menu:");
System.out.println("1. Deposit");
System.out.println("2. Withdraw");
System.out.println("3. Check Balance");
System.out.println("4. Exit ");
System.out.println("Enter your chioce: ");
choice = input.nextInt();
switch (choice){
case 1:
System.out.print("Enter amount to deposit: ");
deposit = input.nextDouble();
balance += deposit;
System.out.println("Deposited: $" + deposit+ " and ur balance is "+balance);
break;
case 2:
System.out.print("Enter amount to withdraw: ");
withdraw = input.nextDouble();
if(withdraw > balance){
System.out.print("insufficient balance ");
} else {
System.out.println("Withdraw : $" + withdraw);
}
break;
case 3:
balance -= withdraw ;
System.out.println("Current Balance: $" + balance);
break;
case 4:
System.out.println("Exiting... Thank you! ");
break;
}
}
}
}