-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathATM.c
More file actions
65 lines (52 loc) · 1.69 KB
/
Copy pathATM.c
File metadata and controls
65 lines (52 loc) · 1.69 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
64
65
#include <stdio.h>
int main() {
int pin = 1234, enteredPin, choice;
float balance = 5000.00, amount;
printf("--- ATM System ---\n");
printf("Enter PIN: ");
scanf("%d", &enteredPin);
if (enteredPin != pin) {
printf("Incorrect PIN! Access denied.\n");
return 0;
}
do {
printf("\n--- ATM Menu ---\n");
printf("1. Check Balance\n");
printf("2. Deposit Money\n");
printf("3. Withdraw Money\n");
printf("4. Exit\n");
printf("Enter choice: ");
scanf("%d", &choice);
switch (choice) {
case 1:
printf("Current Balance: %.2f\n", balance);
break;
case 2:
printf("Enter deposit amount: ");
scanf("%f", &amount);
if (amount > 0) {
balance += amount;
printf("Deposit successful!\n");
} else {
printf("Invalid amount!\n");
}
break;
case 3:
printf("Enter withdraw amount: ");
scanf("%f", &amount);
if (amount > 0 && amount <= balance) {
balance -= amount;
printf("Withdraw successful!\n");
} else {
printf("Insufficient balance or invalid amount!\n");
}
break;
case 4:
printf("Thank you for using ATM.\n");
break;
default:
printf("Invalid choice!\n");
}
} while (choice != 4);
return 0;
}