| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 2235 人关注过本帖
标题:用了gerchar(),屏幕还是一闪而过怎么办(自动取款机的程序)
只看楼主 加入收藏
Angel乖乖
Rank: 1
等 级:新手上路
帖 子:70
专家分:3
注 册:2011-5-14
收藏
得分:0 
程序代码:
#include <iostream>

 #include <string>


 #define error 0

 #define succee 1

 using namespace std;

 class ACCOUNT

 {

 private:
     unsigned long ID;
     unsigned int password;
     string name;
     int ballance;

 public:
     ACCOUNT(unsigned long id,unsigned int pw,string n,int a);

    int cunkuan(unsigned long id,unsigned int pw,int a);
     int qukuan(unsigned long id,unsigned int pw,int a);
     int chaxun(unsigned long id,unsigned int pw);
     int check(unsigned long id,unsigned int pw);

 };

 ACCOUNT::ACCOUNT(unsigned long id,unsigned int pw,string n,int a)

 {
     ID=id;
     password=pw;
     name = n;
     ballance=a;

}

 int ACCOUNT::cunkuan(unsigned long id,unsigned int pw,int a)

 {
     if(!check(id,pw))
         return error;
     else
     {
         ballance+=a;
         return succee;
         cout<<"您的余额为:"<<ballance<<endl;
     }

 }

 int ACCOUNT::qukuan(unsigned long id,unsigned int pw,int a)

 {
     switch(a)
     {
     case 1:a=100;
              break;
    case 2:a=200;
              break;
     case 3:a=500;
              break;
    case 4:a=1000;
            break;
     }
             

     if(!check(id,pw))
      return error;
   
     else
     {
         if(ballance<a)
         {
             cout<<"您的余额已不足!"<<endl;
         return error;
         }
         else
             ballance-=a;
         return ballance;
     }
   

 }

 int ACCOUNT::chaxun(unsigned long id,unsigned int pw)

 {
   
   
     if(!check(id,pw))
         return error;
     else
         return ballance;

 }

 int ACCOUNT::check(unsigned long id,unsigned int pw)

 {
     if(id==ID&&pw==password)
         return succee;
     else
         return error;

 }

 int main()

 {
     ACCOUNT A(1005170228,123456,"Angel",500);
     int c;
     unsigned long id;
     unsigned int pw;
     int a;
     cout<<"欢迎使用"<<endl;
     cout<<"-----------------------"<<endl;
     cout<<"<1>存款\n<2>取款\n<3>查询余额\n<4>结束"<<endl;
     cout<<"请选择:"<<endl;

     cin>>c;
     getchar();
     while(c!=4)
     {
         switch(c)
         {
         case 1:
             cout<<"请输入账号:"<<endl;
             cin>>id;
             cout<<"请输入密码:"<<endl;
             cin>>pw;
             cout<<"请输入存款金额:"<<endl;
             cin>>a;
             if(A.cunkuan(id,pw,a))
             {
                 cout<<"操作成功,您目前的余额为 "<<endl;

                cout<<A.chaxun(id,pw)<<""<<endl;
             }
             else
                 cout<<"操作失败!"<<endl;
             getchar();
             break;
         case 2:
             cout<<"请输入账号:"<<endl;
             cin>>id;
             cout<<"请输入密码:"<<endl;
             cin>>pw;
             cout<<"请选择取款余额:\t<1>100\t<2>200\t<3>500\t<4>1000"<<endl;
             cin>>a;
             if(A.qukuan(id,pw,a))
             {
                 cout<<"操作成功,您目前的余额为 "<<endl;
                 cout<<A.chaxun(id,pw)<<""<<endl;
             }
             else
             {
               
                 cout<<"操作失败!"<<endl;
             }
             getchar();
             break;
         case 3:
             cout<<"请输入账号:"<<endl;
             cin>>id;
             cout<<"请输入密码:"<<endl;
             cin>>pw;
             if(A.check(id,pw))
             {
                 cout<<"您目前的余额为 "<<endl;
             cout<<A.chaxun(id,pw)<<""<<endl;
             getchar();
             }
             else
             {
                 cout << "★账号或是密码错误!★" << endl;
             }


            break;
         }
         cout<<"-----------------------"<<endl;
         cout<<"请继续选择"<<endl;
         cout<<"<1>存款\n<2>取款\n<3>查询余额\n<4>结束"<<endl;
         cin>>c;
     }
     cout<<"谢谢使用!"<<endl;
     getchar();
     getchar();
     return 0;

 }
2011-11-22 23:31
快速回复:用了gerchar(),屏幕还是一闪而过怎么办(自动取款机的程序)
数据加载中...
 
   



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

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