-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathATM.c
95 lines (81 loc) · 2.5 KB
/
ATM.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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
#include <stdio.h>//ATM working using C program
int Transaction();
int anotherTransaction,amountToWithdraw,amountToDeposit,pin;
double balance = 500; // setting initial balance for everyone
int main()
{
printf("\n");
printf("******** Welcome VYS ATM !! ******** \n\n");
printf(" Enter your pin number please: \n");
scanf("%d",&pin);
if(pin != 1221)
{
printf("Sorry your pin is wrong, Pls try again ");
}
else
{
Transaction();
}
}
int Transaction()
{
int choice;
printf("Enter any option to use!\n\n");
printf("1. Balance Enquiry \n");
printf("2. Cash Withdraw\n");
printf("3. Deposit Cash\n");
printf("4. Exit \n");
scanf("%d", &choice);
switch(choice)
{
case 1:
printf("Your bank balance is: %f", balance);
printf("\n\nDo you want to perform another transaction?\nPress 1 to proceed and 0 to exit\n\n"); // request for another transaction
scanf("%d",&anotherTransaction);
if(anotherTransaction == 1)
{
Transaction();
}
break;
case 2:// Second option should be withdraw
printf("Please enter amount to withdraw: ");
scanf("%d", &amountToWithdraw);
if(amountToWithdraw <= balance) //500
{
printf("Pls collect your cash\n");
balance=balance-amountToWithdraw;//
printf("Your available balance is %lf\n",balance);
printf("\n\nDo you want to perform another transaction?\n Press 1 to proceed and 0 to exit\n\n");
scanf("%d", &anotherTransaction);
if(anotherTransaction == 1)
{
Transaction();
}
}
else
{
printf("Sorry in-sufficient funds in your account");
printf("\n\nDo you want to perform another transaction?\n Press 1 to proceed and 0 to exit\n\n");
scanf("%d", &anotherTransaction);
if(anotherTransaction == 1)
{
Transaction();
}
}
break;
case 3:
printf("Please enter amount to deposit: ");
scanf("%d", &amountToDeposit);
balance = amountToDeposit + balance;
printf("Thank you for depositing, your new balance is: %f", balance);
printf("\n\nDo you want another transaction?\nPress 1 to proceed and 0 to exit\n\n");
scanf("%d", &anotherTransaction);
if(anotherTransaction == 1)
{
Transaction(); // call our transaction method here
}
break;
default:
printf("Thanks for Using ATM services, See you soon");
}
}