第十二周项目4-银行系统(一)
任务1——搭一个框架
用const定义全局的常变量password,作为银行卡的密码。
判断输入的密码是否正确,如果不正确,提示,否则,继续下面的工作。
用switch多分支完成显示。
/* *Copyright (c) 2014,烟台大学计算机学院 *All gight reserved. *文件名称:temp.cpp *作者:邵帅 *完成时间:2014年11月12日 *版本号:v1.0 */ #include<iostream> using namespace std; const int password=123456; double money; int main() { int pass,choice; cout << "麻鱼银行欢迎您的光临!" << endl; cout << "请输入密码:"; cin>>pass; if (pass==password) { while (choice != 0) { cout << "* 您可以办理下面的业务:" << endl; cout << "* 1.查询" << endl; cout << "* 2.取款" << endl; cout << "* 3.存款" << endl; cout << "* 4.转账" << endl; cout << "* 0.退出" << endl; cout << "* 请输入(0~4):"; cin >> choice; switch (choice) { case 0: cout<<"欢迎下次光临!"<<endl; break; case 1: case 2: case 3: case 4: cout<<"系统正在建设中..."<<endl; break; default: cout<<"输入错误,请重新输入。"<<endl; continue; } } } else { cout<<"密码输入错误!"<<endl; } }运行结果:
@ Mayuko