| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 348 人关注过本帖
标题:一个自动柜员机程序,无法执行到case内,怎么修改?
只看楼主 加入收藏
bruse
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-11-8
收藏
 问题点数:0 回复次数:0 
一个自动柜员机程序,无法执行到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();
}
搜索更多相关主题的帖子: double balance private long include 
2007-11-08 15:51
快速回复:一个自动柜员机程序,无法执行到case内,怎么修改?
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.019116 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved