主题:创建用户能识别字符,并做出处理
#include <iostream>
using namespace std;
unsigned int count_code;
float count_meney = 0;
float count_rat = 0;
float del = 0;
void error(){
cout<<"无效操作!"<<endl;
}
void show(){
int b;
count_meney -= del;
cout <<"帐号:"<<count_code<<endl;
cout <<"余额:"<<count_meney<<endl;
cout <<"利息: "<<count_rat<<endl;
cout <<"月后余额为:"<<count_meney+count_meney*count_rat<<endl;
cout <<"返回主菜单请按0"<<endl;
cin >> b;
}
int main(void){
int a;
//menu
for(;;){
cout<<" 迷你银行系统 "<<endl;
cout<<"----------------------"<<endl;
cout<<"①创建count"<<endl;
cout<<"②存款"<<endl;
cout<<"③取款"<<endl;
cout<<"④调整利息"<<endl;
cout<<"⑤显示账户信息"<<endl;
cout<<"Exit:please enter 0 key"<<endl;
cout<<"----------------------"<<endl;
cout<<"\a请选择:";
cin>>a;
switch (a){
case 0: return 0;
case 1:for(;;)
{cout<<"请输入需要创建的帐号名:(数字)"<<endl;
cin>>count_code;
if(count_code)
{cout<<"Create Success!"<<endl;
break;
}
else error();
}
break;
case 2:cout<<"请输入需要存入金额:"<<endl;
cin>>count_meney;
break;
case 3:cout<<"请输入需要取款金额:"<<endl;
cin>>del;
break;
case 4:cout<<"请输入调整利率:(小于100%)"<<endl;
cin>>count_rat;
break;
case 5:cout<<"用户信息如下:"<<endl;
show();
break;
}
}
return 0;
}
创建帐号时,输入字符或字符串能报错。怎么修改主程序。