-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathATM service in C program.c
68 lines (68 loc) · 1.64 KB
/
ATM service in C program.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
/* C Program to Display the ATM Service */
#include <stdio.h>
unsigned long amount=1000,deposit,withdraw;
int choice,pin,k;
char transaction='y';
void main()
{
while(pin!=1234)
{
printf("ENTER YOUR SECRET PIN NUMBER: ");
scanf("%d",&pin);
if (pin!=1234)
printf("PLEASE ENTER VALID PASSWORD.\n");
}
do
{
printf("\n********Welcome to ATM Service*********\n");
printf("\t1. Check Balance\n");
printf("\t2. Withdraw Cash\n");
printf("\t3. Deposit Cash\n");
printf("\t4. Quit\n");
printf("\n***************************************\n\n");
printf("Enter your choice: ");
scanf("%d",&choice);
switch(choice)
{
case 1:
printf("\nYOUR BALANCE IS = %lu ",amount);
break;
case 2:
printf("\nENTER THE AMOUNT TO WITHDRAW: ");
scanf("%lu",&withdraw);
if(withdraw%100!=0)
{
printf("\nPLEASE ENTER THE AMOUNT IN MULTIPLES OF 100");
}
else if(withdraw>(amount-500))
{
printf("\nINSUFFICENT BALANCE.");
}
else
{
amount=amount-withdraw;
printf("\n\nPLEASE COLLECT YOUR CASH.");
printf("\nYOUR CURRENT BALANCE IS =%lu",amount);
}
break;
case 3:
printf("\nENTER THE AMOUNT TO DEPOSIT = ");
scanf("%lu",&deposit);
amount=amount+deposit;
printf("YOUR BALANCE IS = %lu",amount);
break;
case 4:
printf("\nTHANK U USING ATM");
break;
default:
printf("\nINVALID CHOICE");
}
printf("\n\nDO U WISH TO HAVE ANOTHER SERVICE?(y/n): \n");
fflush(stdin);
scanf("%c",&transaction);
if (transaction=='n'||transaction=='N')
k=1;
}
while (!k);
printf("\n\nTHANKS FOR USING OUR ATM SERVICE.");
}