forked from Anurag2622002/Codefornewccoder
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatm.c
84 lines (72 loc) · 2.17 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
#include <stdio.h>
#include <conio.h>
int currentbal,initialbal,withdraw,deposit,choice,i,pin;
float principal, t, rate, SI;
char transaction ='y';
int main()
{
while (pin != 3579)
{
printf("ENTER YOUR PIN NUMBER: ");
scanf("%d", &pin);
if (pin != 3579)
printf("PLEASE ENTER VALID PASSWORD\n");
}
printf("Enter initial balance:\n");
scanf("%d",&initialbal);
do{
printf("Select your choice:");
printf("*********Welcome to ATM Service*********\n");
printf("1. Check Balance\n");
printf("2. Deposit Cash\n");
printf("3. Withdraw Cash\n");
printf("4. View previous transaction\n");
printf("5. Calculate interest accrued in the account\n");
printf("6. Exit the application\n");
printf("Enter your choice: \n");
scanf("%d", &choice);
switch(choice)
{
case 1:
printf("The current balance is Rs.%d", currentbal );
break;
case 2:
printf("Enter the amount to deposit in the account: \n");
scanf("%d", &deposit);
currentbal = initialbal + deposit;
break;
case 3:
printf("Enter the amount to withdraw from the account: \n");
scanf("%d", &withdraw);
currentbal = currentbal - withdraw;
break;
case 4:
if(currentbal>initialbal)
printf("The overall deposit is made of Rs. %d\n", currentbal - initialbal);
else
printf("The overall withdrawal is made of Rs. %d\n", initialbal - currentbal);
break;
case 5:
printf("Enter the principal amount: ");
scanf("%f", &principal);
printf("Enter the time period: ");
scanf("%f", &t);
printf("Enter the rate of interest: ");
scanf("%f", &rate);
SI = (principal * t * rate) / 100;
printf("Simple Interest for Principal Amount %.2f is %.2f", principal, SI);
break;
case 6:
printf("Exiting Program\n");
break;
default:
printf("\n INVALID CHOICE");
}
printf("\n\n\n DO U WISH TO HAVE ANOTHER TRANSCATION?(y/n): ");
fflush(stdin);
scanf("%c", &transaction);
if (transaction == 'n'|| transaction == 'N')
i = 0;
} while (!i);
printf("\n\n THANKS FOR USING OUR ATM SERVICE");
}