forked from DHEERAJHARODE/Hacktoberfest2024-Open-source-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathatm.c
89 lines (87 loc) · 2.11 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
#include <stdio.h>
#include <stdlib.h>
int main()
{
main:
float x,y;
char ch;
char choice;
printf(" =======================================================");
printf("\n | ATM MACHINE |");
printf("\n ========================================================");
printf("\nEnter initial amount: ");
scanf("%f",&x);
printf("\n**********************ATM SERVICES*************************");
printf("\nEnter c for credit.\nEnter d for debit.\nEnter b for balance.\n ");
scanf("\n%c", &ch);
printf("\n************************************************************");
switch(ch)
{
case 'c':
printf("\n Enter credit amount:");
scanf("%f",&y);
x=x+y;
printf("\n New Amount = %f",x);
printf("\n PRESS b TO GO BACK:");
scanf("\n%c",&choice);
system("cls");
if(choice=='b')
{
goto main;
}
else
{
break;
}
case 'd':
printf("\n Enter debit amount:");
scanf("%f",&y);
if(x>=y)
{
x=x-y;
printf("\n New amount = %f",x);
}
else
{
printf("\n Insufficient amount in your account");
}
printf("\n PRESS b TO GO BACK:");
scanf("\n%c",&choice);
system("cls");
if(choice=='b')
{
goto main;
}
else
{
break;
}
case 'b':
printf("\n Amount in your account is = %f",x);
printf("\n PRESS b TO GO BACK:");
scanf("\n%c",&choice);
system("cls");
if(choice=='b')
{
goto main;
}
else
{
break;
}
default:
printf("\n Invalid choice.");
printf("\n PRESS b TO GO BACK:");
scanf("\n%c",&choice);
system("cls");
if(choice=='b')
{
goto main;
}
else
{
break;
}
}
return 0;
}