借鉴别人的ATM程序修改篇
#include<iostream>using namespace std;
int main()
{
bool codes();
void work();
cout<<"欢迎使用ATM"<<endl;
cout<<"请输入6位数密码:";
if(codes())
work();
else
cout<<"对不起,由于你的密码三次输入错误,系统已将你的卡锁定,请拿着相关证件到营业厅解锁"<<endl;
return 0;
}
bool codes()
{
bool code=false;
int mima,num=1;
do
{
if(num>1)
cout<<"(提示:这是第"<<num<<"次输入密码,三次不对你的卡将被锁定!)"<<endl<<"请再次输入密码:";
cin>>mima;
num++;
if(mima==654321)
code=true;
}
while(!code&&num<=3);
return code;
}
void work()
{
char choice;
bool exit = false;
do
{
void showbalance();
void drawmoney();
void deposit();
void transferAccounts();
cout<<endl<<"* 您可以办理下面的业务:"<<endl;
cout<<"* 1.查询"<<endl;
cout<<"* 2.取款"<<endl;
cout<<"* 3.存款"<<endl;
cout<<"* 4.转账"<<endl;
cout<<"* 0.退出"<<endl;
cout<<"* 请输入(0-4):";
cin>>choice;
switch(choice)
{
case '1':
showbalance();
break;
case '2':
drawmoney();
break;
case '3':
deposit();
break;
case '4':
transferAccounts();
break;
case '0':
cout<<"欢迎再次使用!"<<endl;
exit=true;
}
}while(!exit);
return;
}
void showbalance()
{
cout<<"您的余额为****"<<endl;
}
void drawmoney()
{
double money;
cout<<"请输入取款金额:";
cin>>money;
cout<<" 对不起,您的余额已不足!";
}
void deposit()
{
int type, days;
double moneys, period, rate, interest;
cout<<"请输入存款金额:";
cin>>moneys;
cout<<"======存款期限======"<<endl;
cout<<"1. 活期存款"<<endl;
cout<<"2. 3个月"<<endl;
cout<<"3. 6个月"<<endl;
cout<<"4. 一年 "<<endl;
cout<<"5. 二年"<<endl;
cout<<"6. 三年"<<endl;
cout<<"7. 五年"<<endl;
cout<<"请输入存款期限的代号:";
cin>>type;
if (type>=1 && type<=7)
{
switch(type)
{
case 1:
cout<<"请输入存款天数:";
cin>>days;
period=days/360.0;
rate=0.005;
break;
case 2:
period=0.25;
rate=0.031;
break;
case 3:
period=0.5;
rate=0.033;
break;
case 4:
period=1;
rate=0.035;
 
补充:软件开发 , C++ ,