自编模拟ATM(自动柜员机)界面程序代码
#include<iostream.h>#include <stdlib.h>
void main()
{
cout<<"欢迎使用"<<endl;
char ch,p;
cout<<"=====================\n";
cout<<" a取钱"<<endl;
cout<<" b存钱"<<endl;
cout<<" c查询余额"<<endl;
cout<<" d取卡"<<endl;
cout<<"=====================\n";
cout<<"请输入你想执行的:";
cin>>ch;
while(ch!='a'&&ch!='b'&&ch!='c'&&ch!='d')
{
cout<<"你输入有误,请重新输入";
cin>>ch;
}
cout<<"======================!";
int i,j;
system("cls");
while(ch!='d')
{
switch(ch)
{
case'a':
{
cout<<"请选择你要取出的金额\n";
cout<<"1.$50\n";
cout<<"2.$100\n";
cout<<"3.$200\n";
cout<<"4.退出 \n";
cin>>p;
while(p!='1'&&p!='2'&&p!='3'&&p!='4')
{
cout<<"你输入有误,请重新输入";
cin>>p;
}
system("cls");
switch(p)
{
case'1':cout<<"you gredit money is $50,thank you!\n";break;
case'2':cout<<"you gredit money is $100,thank you!\n";break;
case'3':cout<<"you gredit money is $200,thank you!\n";break;
case'4':cout<<"thank you for using!\n";break;
}
break;
}
case'b':
{
int o;
cout<<"请输入你要存人的数额:"<<endl;
cin>>o;
int w;
cout<<"请输入帐号:"<<endl;
cin>>w;
cout<<"你存入了"<<o<<"到帐号"<<w<<endl;
system("cls");
cout<<"thank you for useing"<<endl;
break;
}
case'c':
{
cout<<"你的余额为$1000\n";
break;
}
}
break;
cout<<"thank you for useing"<<endl;
}
}
感觉里面有不好的地方.请高手指教下..比如如何能在存钱里限制只能输入数字的限制..