-
Notifications
You must be signed in to change notification settings - Fork 0
/
AtmInterfacejava
51 lines (40 loc) · 1.43 KB
/
AtmInterfacejava
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
import java.util.Scanner;
public class AtmInterface {
public static void main(String[] args){
Scanner sc = new Scanner(System.in);
int balance = 10000, deposit, withdraw;
while (true) {
System.out.println("choose 1 for deposit:");
System.out.println("choose 2 for withdraw:");
System.out.println("choose 3 for balance inquiry:");
System.out.println("choose 4 for exit:");
System.out.println("choose correct operation to perform:");
int choice = sc.nextInt();
switch(choice){
case 1:
System.out.println("Enter amount you want to deposit:");
deposit = sc. nextInt();
balance = balance + deposit;
System.out.println("your updated balance is :"+balance);
System.out.println();
break;
case 2:
System.out.println("enter amount to withdraw:");
withdraw = sc.nextInt();
if(balance >= withdraw){
balance = balance - withdraw;
System.out.println("your updated balance is :"+balance);
} else {
System.out.println("insufficiant funds...!");
}
break;
case 3:
System.out.println("your account balance is :"+balance);
System.out.println();
break;
case 4:
System.exit(0);
}
}
}
}