银行业务系统2

/* 
 *Copyright (c) 2014,烟台大学计算机学院 
 *All gight reserved. 
 *文件名称:temp.cpp 
 *作者: 
 *完成时间:2014年11月 
 *版本号:v1.0 
*/  
#include<iostream>  
using namespace std;  
int password;  
double money;  
bool pass();  
void work();  
void exit();  
void showbalance();  
double drawmoney(double money);  
double deposit(double money);  
double transferAccounts(double money);  
int updatePassword(int password);  
int main()  
{  
    password=123456;  
    money=10000;  
    cout << "麻鱼银行欢迎您的光临!" << endl;  
    cout << "请输入密码:";  
    if (pass())  
    {  
        cout<<endl;  
        work();  
    }  
    else  
        cout << "请到柜台办理密码查询后再来。" << endl;  
    return 0;  
}  
  
bool pass()     // 输入密码函数&判断  
{  
    int i = 1, pass;  
    bool passtrue = false;  
    do  
    {  
        cin >> pass;  
        if (pass == password)  
        {  
            passtrue = true;  
            return passtrue;  
        }  
        else  
        {  
            i++;  
            if (i < 4)  
                cout << "密码输入错误" << i-1 << "次,再输错" << 4 - i << "次将要吞卡。" << endl;  
            else if (i = 4)  
                cout << "银行卡已被吞。" << endl;  
            continue;  
        }  
    }  
    while (passtrue = false || i < 4);  
}  
  
void work()  
{  
    int choice;  
    while (choice != 0)  
    {  
        cout << "* 您可以办理下面的业务:" << endl;  
        cout << "* 1.查询 2.取款 3.存款 4.转账 5.改密 0.退出" << endl;  
        cout << "* 请输入(0~5):";  
        cin >> choice;  
        switch (choice)  
        {  
        case 0:  
            exit();  
            break;  
        case 1:  
            showbalance();  
            break;              // 查询  
        case 2:  
            money=drawmoney(money);  
            break;              // 取款  
        case 3:  
            money=deposit(money);  
            break;              // 存款  
        case 4:  
            money=transferAccounts(money);  
            break;              // 转账  
        case 5:  
            password=updatePassword(password);  
            break;              // 改密  
        default:  
        {  
            cout << "输入错误,请重新输入。" << endl;  
            continue;  
        }  
        }  
    }  
}  
  
void exit()  
{  
    cout << "欢迎下次光临。" << endl;  
}  
  
void showbalance()  
{  
    cout << "您当前的账户余额为:" << money << "元。" << endl<< endl;  
    work();  
}  
  
double drawmoney(double money)  
{  
    double outmoney;  
    while (1)  
    {  
        cout << "请输入取款金额:";  
        cin >> outmoney;  
        if (outmoney > money)  
        {  
            cout << "对不去,余额不足。" << endl;  
            continue;  
        }  
        else  
        {  
            money -= outmoney;  
            cout << "取款后,您的余额是:" << money << "元" <<endl<<endl;  
        }  
        return money;  
    }  
}  
  
double deposit(double money)  
{  
    double inmoney;  
    cout << "请输入存款金额:";  
    cin >> inmoney;  
    money += inmoney;  
    cout << "存款后,您的余额是:" << money << "元。" << endl<<endl;  
    return money;  
}  
  
double transferAccounts(double money)  
{  
    double changemoney, otheraccount;  
    while (1)  
    {  
        cout << "请输入转账金额:";  
        cin >> changemoney;  
        cout << "请输入对方账户:";  
        cin >> otheraccount;  
        if (otheraccount > money)  
        {  
            cout << "对不去,余额不足,请重新输入。" << endl;  
            continue;  
            cout << endl;  
        }  
        else  
        {  
            money -= changemoney;  
            cout<<"汇款成功!"<<"您成功汇款"<<changemoney<<"元。"<<endl;  
            cout<<"您的余额:"<<money<<"元。"<<endl<<endl;  
            return money;  
        }  
    }  
}  
  
int updatePassword(int password)  
{  
    int pass_1, pass_2;  
    while (1)  
    {  
        cout << "请输入旧密码:";  
  
        if (pass())  
        {  
            cout << "请输入新密码:";  
            cin >> pass_1;  
            cout << "请确认新密码:";  
            cin >> pass_2;  
            if (pass_1 == pass_2)  
            {  
                password = pass_1;  
                cout << "密码修改成功!" << endl<<endl;  
                return password;  
                cout << endl;  
                work();  
            }  
            else  
            {  
                cout << "两次密码输入不一致,请重新输入!" <<  
                     endl;  
                continue;  
            }  
        }  
        else  
        {  
            cout << "请联系客服。" << endl;  
            continue;  
        }  
    }  
}  

运行结果:
<span style="color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;">运行结果:</span><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;"></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;"><span style="font-family: SimSun; font-size: 12px;"><img src="https://img-blog.csdn.net/20141112225358282?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbWF5dWtvMjAxMg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" style="border: none;" />
</span></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;"><span style="font-family: SimSun; font-size: 12px;"><img src="https://img-blog.csdn.net/20141112225407845?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbWF5dWtvMjAxMg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" style="border: none;" />
</span></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;"><span style="font-family: SimSun; font-size: 12px;"><img src="https://img-blog.csdn.net/20141112225454598?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbWF5dWtvMjAxMg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" style="border: none;" />
</span></p><p style="margin-top: 0px; margin-bottom: 0px; padding-top: 0px; padding-bottom: 0px; color: rgb(85, 85, 85); font-family: 'microsoft yahei'; font-size: 15px; line-height: 35px;"><img src="https://img-blog.csdn.net/20141112225520526?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvbWF5dWtvMjAxMg==/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" style="border: none; max-width: 602px; height: auto;" />
</p><div>
</div>
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值