-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathATM01.cpp
More file actions
186 lines (177 loc) · 3.75 KB
/
ATM01.cpp
File metadata and controls
186 lines (177 loc) · 3.75 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
// ATM01.cpp : 定义控制台应用程序的入口点。
//
#include "stdafx.h"
#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
long float m = 1000;
int language()
{
printf("=======================\n");
printf("| 1.中文 |\n");
printf("| 2.English |\n");
printf("| 3.退出\\Exit |\n");
printf("=======================\n");
return _getch();
}
void mainmenu1()
{
printf("=======================\n");
printf("| 1.查询 |\n");
printf("| 2.存钱 |\n");
printf("| 3.取钱 |\n");
printf("| 4.退出 |\n");
printf("=======================\n");
}
void mainmenu2()
{
system("cls");
printf("=======================\n");
printf("| 1.Query |\n");
printf("| 2.Deposit |\n");
printf("| 3.Withdraw |\n");
printf("| 4.Exit |\n");
printf("=======================\n");
}
void query1()
{
system("cls");
printf("=======================\n");
printf("此账户有 ¥%.2lf 元.\n", m);
printf("请按任意键继续 \n");
printf("=======================\n");
_getch();
system("cls");
}
void query2()
{
system("cls");
printf("=========================================\n");
printf("This account balance is ¥ %.2lf .\n", m);
printf("Press any key to continue\n");
printf("=========================================\n");
_getch();
system("cls");
}
void deposit1()
{
system("cls");
float a;
printf("=======================\n");
printf("请输入您要存的数目: ¥ ");
scanf_s("%f", &a);
m = m + a;
printf("请按任意键继续\n");
printf("=======================\n");
_getch();
system("cls");
}
void deposit2()
{
system("cls");
long float a;
printf("================================================\n");
printf("Please enter the amount you want to save: ¥ ");
scanf_s("%lf", &a);
m = m + a;
printf("Press any key to continue\n");
printf("================================================\n");
_getch();
system("cls");
}
void withdraw1()
{
system("cls");
long float a;
printf("=======================\n");
printf("请输入您要取的数目: ¥ ");
scanf_s("%lf",&a);
while (a>m)
{
printf("余额不足,按任意键后重新输入!");
_getch();
system("cls");
printf("=======================\n");
printf("请输入您要取的数目: ¥ ");
scanf_s("%lf", &a);
}
m = m - a;
printf("请按任意键继续\n");
printf("=======================\n");
_getch();
system("cls");
}
void withdraw2()
{
system("cls");
long float a;
printf("=====================================================\n");
printf("Please enter the amount you want to withdraw:¥ ");
scanf_s("%lf", &a);
while (a >= 0)
{
}
while (a>m)
{
printf("Lack of balance, press any key to enter the amount!");
_getch();
system("cls");
printf("=====================================================\n");
printf("Please enter the amount you want to withdraw:¥ ");
scanf_s("%lf", &a);
}
m = m - a;
printf("Press any key to continue\n\n");
_getch();
system("cls");
}
void main()
{
int bExit = 0; int in; char n = language();
if (n == '1')
{
system("cls");
while (!bExit)
{
mainmenu1();
in = _getch();
switch (in)
{
case '1':
query1(); break;
case '2':
deposit1(); break;
case'3':
withdraw1(); break;
case '4':
bExit = 1; break;
default:
system("cls");
break;
}
}
}
if (n == '2')
{
system("cls");
while (!bExit)
{
mainmenu2();
in = _getch();
switch (in)
{
case '1':
query2(); break;
case '2':
deposit2(); break;
case'3':
withdraw2(); break;
case '4':
bExit = 1; break;
default:
system("cls");
break;
}
}
}
}