一个自动柜员机程序,无法执行到case内,怎么修改?
编译没有什么问题,可是运行的时候程序没有执行到case内,大伙帮忙看看怎么改?#include<iostream>
#include<string>
#include<conio.h>
using namespace std;
enum Result{FAIL=0,SUCC};
class Account{ //define class
private:
unsigned long ID;
unsigned int pw;
char name[10];
double balance;
public:
Account(unsigned long,unsigned int,char *,double);
Result deposit(unsigned long,unsigned int,double);
Result drawing(unsigned long,unsigned int,double);
double chk_balance(unsigned long,double);
Result check(unsigned long,unsigned int);
};
Account::Account(unsigned long ID,unsigned int password,char *n,double m)
:ID(ID),pw(pw),balance(m)
{strcpy(name,n);
}
Result Account::deposit(unsigned long ID,unsigned int pw,double m)
{ if(check(ID,pw))
return FAIL;
else
{
balance+=m;
return SUCC;
}
}
Result Account::drawing(unsigned long ID,unsigned int pw,double m)
{if(check(ID,pw)&&balance>=m)
return FAIL;
else
{
balance-=m;
return SUCC;
}
}
double Account::chk_balance(unsigned long ID,double pw)
{if(check(ID,pw))
return balance;
else return(double) FAIL;
}
Result Account::check(unsigned long,unsigned int)
{if(ID==ID&&pw==pw)
return SUCC;
else
return FAIL;
}
main() // the main function
{
Account testacc(8816001,1231,"AAAA",1000);
int choice;
unsigned long ID;
unsigned int pw;
double m;
do{
cout<<"\nauto drawing maching\n";
cout<<"*****************\n";
cout<<"<1> deposit\n";
cout<<"<2> drawing\n";
cout<<"<3> check balance\n";
cout<<"<4> end\n";
cout<<"please choice:";
cin>>choice;
switch(choice) //operation
{
case1:
cout<<"please enter account ID:";
cin>>ID;
cout<<"please enter password:";
cin>>pw;
cout<<"please enter the deposit account:";
cin>>m;
if(testacc.deposit(ID,pw,m))
{
cout<<"success deposit! your current balance is:";
cout<<testacc.chk_balance(ID,pw)<<"dollors";
}
else cout<<"deposit fail,maybe is wrongID or password!";
break;
case2:
cout<<"please enter account ID:";
cin>>ID;
cout<<"please enter password:";
cin>>pw;
cout<<"please enter the drawing account:";
cin>>m;
if(testacc.drawing(ID,pw,m))
{
cout<<"success drawing! your current balance is:";
cout<<testacc.chk_balance(ID,pw)<<"dollors";
}
else cout<<"drawing fail,maybe is wrongID or password!";
break;
case3:
cout<<"please enter account ID:";
cin>>ID;
cout<<"please enter password:";
cin>>pw;
m=testacc.chk_balance(ID,pw);
if(m)
{
cout<<"your current balance is:";
cout<<m<<"$";
}
else cout<<"check fail,maybe is wrongID or password or others!";
break;
}
}
while(choice!=4);
cout<<"thank for your using!";
getch();
}