-
Notifications
You must be signed in to change notification settings - Fork 0
/
simple-bank-atm(emulator).c
81 lines (53 loc) · 2.25 KB
/
simple-bank-atm(emulator).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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#include <stdio.h>
#define PIN 1234
#define MONEY 2340
int customer_pin=0,i=0,k;
float new_money=0,removed_money=0,final_money=0;
int main (void) {
printf ("Welcome!!!");
for (i=3;i>0;i--)
{ printf ("\n\nPlease insert your PIN: ");
scanf ("%d", &customer_pin);
if (customer_pin!=PIN) {
printf ("Wrong pin: (%d tries remaining)", i-1);
if (i==1) return 0;}
else { printf ("\n\n\nClient Authenticated!\n\nPlease press one of the above numbers to complete your transaction");
printf ("\n\n 1. Import Money\n 2. Deposit Money\n 3. Account Info \n\nYour number: ");
int j=0;
scanf ("%d", &j);
if (j==1)
{printf ("\nHow many money you want to add: ");
scanf("%f", &new_money);
final_money=MONEY+new_money;
printf ("\n\nYour Balance is= %.2f EUR", final_money);
printf("\n\n\nThanks for using our system\nTransaction ended!\n");
printf ("Enter any key to exit: ");
scanf ("%d", &k);
break;
}
else if (j==2)
{printf ("\nHow many money you want to deposit: ");
scanf ("%f", &removed_money);
if (removed_money>MONEY) {
printf ("\n\nNot enough money you will get only: %d EUR", MONEY);
final_money=MONEY-MONEY;
printf ("\nYour Balance is= %.2f EUR", final_money);
printf("\n\n\nThanks for using our system\nTransaction ended!\n");
printf ("Enter any key to exit: ");
scanf ("%d", &k);
break;
}
final_money=MONEY-removed_money;
printf ("\nYour Balance is= %.2f EUR", final_money);
printf("\n\n\nThanks for using our system\nTransaction ended!\n");
printf ("Enter any key to exit: ");
scanf ("%d", &k);
break;
}
else if (j==3)
{printf ("\nYour Balance is= %d EUR", MONEY);
printf("\n\n\nThanks for using our system\nTransaction ended!\n");
printf ("Enter any key to exit: ");
scanf ("%d", &k);
break;}
} } }