01./*
02.02.02.* 程序的版权和版本声明部分
03.03.03.* Copyright (c)2012, 烟台大学计算机学院
04.04.04.* All rightsreserved.
05.05.05.* 文件名称:银行系统
06.06.06.* 作 者:赵洋
07.07.07.* 完成日期:2012年11月24日
08.08.08.* 版 本 号: v1.0
09.09.09.* 输入描述:
10.10.10.* 问题描述
11.11.11.* 程序输出:
12.12.12.* 问题分析:
13.13.13.*/
#include<iostream>
using namespace std;
const password=123;
double M=8888.88;
void Inquire();
void Fetch();
void Deposit();
void Account();
bool pass();
void work();
int main()
{
cout<<"¥ ¥ ¥ ¥ 欢迎光临朝阳银行!¥ ¥ ¥ ¥"<<endl;
if(pass())
work();
else
cout<<"密码输入有误,请到柜台办理密码业务!"<<endl;
return 0;
}
bool pass()
{
bool f=false;
int pass;
int i=1;
do{
cout<<"请输入密码:";
if(i>1)
cout<<"(提示:这是第"<<i<<"次输入密码,三次不对将吞卡)";
cin>>pass;
i++;
if(pass==password)
f=true;
}while(!f&&i<4);
return f;
}
void work()
{
char cChioce;
bool f = false;
do
{
cout<<"* 1.查询"<<endl;
cout<<"* 2.取款"<<endl;
cout<<"* 3.存款"<<endl;
cout<<"* 4.转账"<<endl;
cout<<"* 0.退出"<<endl;
cout<<"* 请选择(0-4):";
cin>>cChioce;
if(cChioce=='1')
Inquire();
else if(cChioce=='2')
Fetch();
else if(cChioce=='3')
Deposit();
else if(cChioce=='4')
Account();
else if(cChioce=='0')
{
cout<<"谢谢使用,欢迎再次光临!"<<endl;
return ;
}
else
{
continue;
f=true;
}
}while(f);
return ;
}
void Inquire()
{
int h;
cout<<"你的余额是"<<M<<"元!"<<endl;
cout<<"请选择是否继续操作!"<<endl;
cout<<"* 0.退出"<<endl;
cout<<"* 1.继续"<<endl;
cout<<"* 请选择(0-1):";
cin>>h;
if(h==1)
void work();
if(h==0)
{
cout<<"谢谢使用,欢迎再次光临!"<<endl;
return ;
}
}
void Fetch()
{
double money, period, rate, interest,s,S;
int type,days,h;
cout<<"请输入取款金额:";
cin>>money;
cout << "======请您选择存款期限======" << endl;
cout << "======存款期限======" << endl;
cout << "1. 活期存款" << endl;
cout << "2. 3个月 " << endl;
cout << "3. 6个月" << endl;
cout << "4. 一年 " << endl;
cout << "5. 二年" << endl;
cout << "6. 三年" << endl;
cout << "7. 五年" << endl;
cout << "请输入存款期限的代号:";
cin >> type;
if (type>=1 && type <=7)
{
switch(type)
{
case 1:
cout<<"请输入存款天数:";
cin >> days;
period = days/360.0;
rate = 0.005;
break;
case 2:
period = 0.25;
rate = 0.031;
break;
case 3:
period = 0.5;
rate = 0.033;
break;
case 4:
period = 1;
rate = 0.035;
break;
case 5:
period = 2;
rate = 0.044;
break;
case 6:
period = 3;
rate = 0.05;
break;
case 7:
period = 5;
rate = 0.055;
break;
}
interest = money * period * rate;
s=interest + money ;
cout << "到期利息为:" << interest << "元,本息合计共"<<s <<"元。"<<endl;
S=M+s;
cout<<"您当前账户余额为:"<<S<<"元!"<<endl;
cout<<"请选择是否继续操作!"<<endl;
cout<<"* 0.退出"<<endl;
cout<<"* 1.继续"<<endl;
cout<<"* 请选择(0-1):";
cin>>h;
if(h==1)
void work();
if(h==0)
cout<<"谢谢使用,欢迎再次光临!"<<endl;
return ;
}
}
void Deposit()
{
double m,sum;
int h;
cout<<"请输入存款金额!"<<endl;
cin>>m;
sum=m+M;
cout<<"您当前账户余额为"<<sum<<"元!"<<endl;
cout<<"请选择是否继续操作!"<<endl;
cout<<"* 0.退出"<<endl;
cout<<"* 1.继续"<<endl;
cout<<"* 请选择(0-1):";
cin>>h;
if(h==1)
void work();
if(h==0)
cout<<"谢谢使用,欢迎再次光临!"<<endl;
return ;
}
void Account()
{
int x,h;
double y,balance;
cout<<"请输入转入账号:"<<endl;
cin>>x;
cout<<"请输入转账金额:"<<endl;
cin>>y;
if(y>M)
cout<<"余额不足,请重新输入!"<<endl;
else
balance=M-y;
cout<<"转账成功!"<<endl;
cout<<"您当前账户余额为"<<balance<<"元!"<<endl;
cout<<"请选择是否继续操作!"<<endl;
cout<<"* 0.退出"<<endl;
cout<<"* 1.继续"<<endl;
cout<<"* 请选择(0-1):";
cin>>h;
if(h==1)
void work();
if(h==0)
cout<<"谢谢使用,欢迎再次光临!"<<endl;
return ;
}
运行结果: