-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain .c
65 lines (52 loc) · 1.8 KB
/
main .c
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
64
65
#include <stdio.h>
#include <stdlib.h>
int main()
{
int pin = 1234;
int balance = 5000;
int option;
int amount;
printf("Welcome to XYZ Bank ATM\n");
while (1) {
printf("\nPlease enter your PIN: ");
scanf("%d", &pin);
if (pin == 1234) {
printf("\n1. Balance Inquiry\n");
printf("2. Cash Withdrawal\n");
printf("3. Deposit\n");
printf("4. Exit\n");
printf("\nPlease select an option: ");
scanf("%d", &option);
switch (option) {
case 1:
printf("\nYour current balance is: $%d\n", balance);
break;
case 2:
printf("\nPlease enter the amount to withdraw: ");
scanf("%d", &amount);
if (amount > balance) {
printf("\nInsufficient balance\n");
} else {
balance -= amount;
printf("\nTransaction successful. Your new balance is: $%d\n", balance);
}
break;
case 3:
printf("\nPlease enter the amount to deposit: ");
scanf("%d", &amount);
balance += amount;
printf("\nTransaction successful. Your new balance is: $%d\n", balance);
break;
case 4:
printf("\nThank you for using XYZ Bank ATM\n");
exit(0);
default:
printf("\nInvalid option\n");
break;
}
} else {
printf("\nInvalid PIN\n");
}
}
return 0;
}