-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathATM.cpp
More file actions
193 lines (189 loc) · 3.24 KB
/
ATM.cpp
File metadata and controls
193 lines (189 loc) · 3.24 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#include<stdio.h>
#include <conio.h>
#include<time.h>
#include <string.h>
#include <ctype.h>
#include<windows.h>
void clrscr(void)
{
system("cls") ; //clear screen.
}
int wherex()
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE),&csbi);
return csbi.dwCursorPosition.X;
}
int wherey()
{
CONSOLE_SCREEN_BUFFER_INFO csbi;
GetConsoleScreenBufferInfo(GetStdHandle(STD_OUTPUT_HANDLE),&csbi);
return csbi.dwCursorPosition.Y;
}
void gotoxy(short x, short y)
{
COORD pos = {x, y};
SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), pos);
}
void drawbox(int w,int h,int x,int y)
{
int i,ux,uy;
gotoxy(x,y);
putchar('É');
gotoxy(x+w-1,y);
putchar('»');
gotoxy(x,y+h-1);
putchar('È');
gotoxy(x+w-1,y+h-1);
putchar('¼');
for(i=1;i<w-1;i++)
{
gotoxy(x+i,y);
putchar('Í');
gotoxy(x+i,y+h-1);
putchar('Í');
}
for(i=1;i<h-1;i++)
{
gotoxy(x,y+i);
putchar('º');
gotoxy(x+w-1,y+i);
putchar('º');
}
printf("\n");
}
void showMenu()
{
char menu[][50] = {
"SERVICES",
"BANKING",
"MINI STATEMENT",
"BALANCE INFO",
"MOBILE REGISTRATION",
"TRANSFER",
} ;
int maxlen=0,i;
for(i=0;i<6;i++)
{
if(strlen(menu[i])>maxlen)
maxlen=strlen(menu[i]);
}
drawbox(maxlen+6,20,(76-maxlen)/2-2,14);
for(i=0;i<6;i++)
{
if(i==0)
gotoxy((76-maxlen)/2,16);
else
gotoxy((76-maxlen)/2,16+3*i);
printf("%d.%s",i+1,menu[i]);
}
gotoxy((76-maxlen)/2-7,wherey()+6);
printf("ENTER YOUR CHOICE [1/2/3/4/5/6]:-");
}
int len(char *a)
{
int l;
l=strlen(a);
return l;
}
void printhead()
{
char a[]="WELCOME TO STATE BANK OF INDIA";
int l,x;
l=len(a);
x=(75-l)/2;
drawbox(l+4,5,x,1);
gotoxy(x+2,3);
printf("%s",a);
}
void banking()
{
int l,c,maxlen=0,i;
char b[]="PLEASE CHOOSE YOUR DESIRED LANGUAGE:";
char menu[][10]={"ENGLISH",
"HINDI"};
clrscr();
printhead();
gotoxy((75-strlen(b))/2+2,10);
printf("%s",b);
for(i=0;i<2;i++)
{
if(strlen(menu[i])>maxlen)
maxlen=strlen(menu[i]);
}
drawbox(maxlen+6,8,(76-maxlen)/2-2,14);
for(i=0;i<2;i++)
{
if(i==0)
gotoxy((76-maxlen)/2,16);
else
gotoxy((76-maxlen)/2,16+3*i);
printf("%d.%s",i+1,menu[i]);
}
gotoxy((76-maxlen)/2-7,wherey()+6);
printf("ENTER YOUR CHOICE [1/2]:-");
while(1)
{
c=getch();
c-='0';
if(c<1 || c>2)
{
printf("\a");
}
else if(c==2)
{
printf("%d",c);
//gotoxy(0,wherey()+3);
printf("\n\n\nTHIS SERVICE IS TEMPORARY UNAVAILABLE. PLEASE CHOOSE ENGLISH TO CONINUE.\n\n");
}
else
{
printf("%d",c);
break;
}
}
}
int main()
{
int u,c,l;
char a[]="PLEASE SWIPE YOUR CARD BY PRESSING 0.";
printhead();
l=strlen(a);
gotoxy((75-l)/2+2,10);
printf("%s",a);
while(1)
{
printf("\n\n\n");
u=getch();
u-='0';
if(u!=0)
{
printf("\a \n\n\nCARD NOT RECOGNISED.PLEASE SWAP AGAIN.");
}
else
break;
}
clrscr();
printhead();
gotoxy(16,9);
printf("PLEASE CHOOSE \"BANKING\" FOR CASH \"WITHDRAWLS\"");
// drawbox(25,20,26,14);
showMenu();
while(1)
{
c=getch();
c-='0';
if(c<1 || c>6)
printf("\a");
else
{
printf("%d",c);
break;
}
}
switch(c)
{
case 2:banking();
}
// getch();
}