设计并实现简单的银行存取款系统,系统主界面包括登录和注册两个选项,选择登录,提示用户输入银行帐号和密码,验证通过后进入主界面,主界面包括:存款、取款、查询余额、历史记录、修改密码等功能。注册功能让用户输入账号和密码,在注册时要验证账号是否已经存在。所有数据能够保存在文件中,退出系统后再次运行系统,之前注册的用户和存款信息都存在。

  1. #include <iostream>
  2. #include <fstream>
  3. #include <queue>
  4. #include <stdlib.h>
  5. using namespace std;
  6. struct user;
  7. typedef user T;
  8. queue <T> uu;
  9. int count=0;
  10. struct user
  11. {
  12. string id;
  13. string pass;
  14. int n;
  15. double *money;
  16. user() {}
  17. user(string id,string pass,int n,double *money):id(id),pass(pass),n(n),money(money) {}
  18. };
  19. int gongshow();
  20. int gong(string newid);
  21. int save(string newid, string newpass);
  22. int setid(string newid,string newpass);
  23. int main()
  24. {
  25. system("color 0A");
  26. while(1)
  27. {
  28. int m;
  29. string newid,newpass;
  30. cout << "\t\t\t *************************" << endl;
  31. cout << "\t\t\t *Bank Simulation Program*" << endl;
  32. cout << "\t\t\t *************************" << endl;
  33. cout << "\t\t\t * *" << endl;
  34. cout << "\t\t\t * 1.LOG IN *" << endl;
  35. cout << "\t\t\t * 2.ENROLL *" << endl;
  36. cout << "\t\t\t * 3.ESC *" << endl;
  37. cout << "\t\t\t * *" << endl;
  38. cout << "\t\t\t *************************" << endl<<endl;
  39. cout << "\t\t\t Please enter the serial number:";
  40. cin >> m;
  41. if(m==3)
  42. return 0;
  43. system("cls");
  44. cout << "\t\t\t *************************" << endl;
  45. cout << "\t\t\t *Bank Simulation Program*" << endl;
  46. cout << "\t\t\t *************************" << endl<<endl;
  47. cout << "\t\t\t ID:";
  48. cin >> newid;
  49. cout << "\t\t\t PASSWORD:";
  50. cin >> newpass;
  51. int x=save(newid,newpass);// id 1 password 0 no_id 2
  52. if(m==1)
  53. if(x==1)
  54. {
  55. cout << "\t\t\t LOGIN SUCCESSFUL";
  56. system ("pause>nul");
  57. system("cls");
  58. while(1)
  59. {
  60. if(gong(newid)==0) break;
  61. int x=save(newid,newpass);
  62. system ("pause>nul");
  63. system("cls");
  64. }
  65. }
  66. else if(x==2)
  67. {
  68. cout << "\t\t\t ACCOUNT DOS'T EXIST";
  69. system ("pause>nul");
  70. system("cls");
  71. }
  72. else
  73. {
  74. cout << "\t\t\t WRONG PASSWORD";
  75. system ("pause>nul");
  76. system("cls");
  77. }
  78. else if(m==2)
  79. {
  80. if(x==2)
  81. {
  82. if(setid(newid,newpass))
  83. {
  84. cout << "\t\t\t ENROLL SUCCESS";
  85. while(1)
  86. {
  87. while(!uu.empty()) uu.pop();
  88. int x=save(newid,newpass);
  89. system ("pause>nul");
  90. system("cls");
  91. if(gong(newid)==0) break;
  92. }
  93. }
  94. else
  95. {
  96. cout << "\t\t\t ENROLL FAILURE";
  97. system ("pause>nul");
  98. system("cls");
  99. }
  100. }
  101. else if(x==1)
  102. {
  103. cout << "\t\t\t ACCOUNT ALREADY EXISTS";
  104. system ("pause>nul");
  105. system("cls");
  106. }
  107. system("cls");
  108. }
  109. }
  110. return 0;
  111. }
  112. int gongshow()
  113. {
  114. cout << "\t\t\t *************************" << endl;
  115. cout << "\t\t\t *Bank Simulation Program*" << endl;
  116. cout << "\t\t\t *************************" << endl;
  117. cout << "\t\t\t * *" << endl;
  118. cout << "\t\t\t * 1.DPOSIT *" << endl;
  119. cout << "\t\t\t * 2.WITHDRAWALS *" << endl;
  120. cout << "\t\t\t * 3.CHECK BALANCES *" << endl;
  121. cout << "\t\t\t * 4.HISTORY RECORD *" << endl;
  122. cout << "\t\t\t * 5.CHANGE PASSWORD *" << endl;
  123. cout << "\t\t\t * 6.ESC *" << endl;
  124. cout << "\t\t\t * *" << endl;
  125. cout << "\t\t\t *************************" << endl;
  126. cout << endl << "\t\t\t Please enter the serial number:";
  127. int n;
  128. cin >>n;
  129. return n;
  130. }
  131. int gong(string newid)
  132. {
  133. int n=gongshow();
  134. if(n==2||n==1||n==5)
  135. {
  136. fstream f("ios.txt",ios::out);
  137. if(n==1)
  138. {
  139. double n=0;
  140. cout << "\t\t\t Enter deposit amount:";
  141. cin >> n;
  142. while(!uu.empty())
  143. {
  144. if(uu.front().id==newid)
  145. {
  146. f<<uu.front().id<<' '<<uu.front().pass<<' '<<uu.front().n+1<<' ';
  147. for(int i=0; i<uu.front().n; i++)
  148. {
  149. f<< uu.front().money[i]<<' ';
  150. }
  151. f<< uu.front().money[uu.front().n-1]+n<< endl;
  152. cout << "\t\t\t Deposit has been successful";
  153. }
  154. else
  155. {
  156. f<<uu.front().id<<' '<<uu.front().pass<<' '<<uu.front().n<<' ';
  157. for(int i=0; i<uu.front().n; i++)
  158. {
  159. f<< uu.front().money[i]<<' ';
  160. }
  161. f<<endl;
  162. }
  163. uu.pop();
  164. count--;
  165. if(count==1)
  166. uu.pop();
  167. }
  168. }
  169. if(n==2)
  170. {
  171. double n=0;
  172. cout << "\t\t\t Enter the withdrawal amount:";
  173. cin >> n;
  174. while(!uu.empty())
  175. {
  176. if(uu.front().id==newid&&uu.front().money[uu.front().n-1]-n>=0)
  177. {
  178. f<<uu.front().id<<' '<<uu.front().pass<<' '<<uu.front().n+1<<' ';
  179. for(int i=0; i<uu.front().n; i++)
  180. {
  181. f<< uu.front().money[i]<<' ';
  182. }
  183. f<< uu.front().money[uu.front().n-1]-n<< endl;
  184. f<< endl;
  185. cout << "\t\t\t Withdrawals success";
  186. }
  187. else if(uu.front().id!=newid)
  188. {
  189. f<<uu.front().id<<' '<<uu.front().pass<<' '<<uu.front().n<<' ';
  190. for(int i=0; i<uu.front().n; i++)
  191. {
  192. f<< uu.front().money[i]<<' ';
  193. }
  194. f<<endl;
  195. }
  196. else if(uu.front().id==newid&&uu.front().money[uu.front().n-1]-n<0)
  197. {
  198. f<<uu.front().id<<' '<<uu.front().pass<<' '<<uu.front().n<<' ';
  199. for(int i=0; i<uu.front().n; i++)
  200. {
  201. f<< uu.front().money[i]<<' ';
  202. }
  203. f<<endl;
  204. cout << "\t\t\t INSUFFICIENT BALANCE\n";
  205. }
  206. uu.pop();
  207. count--;
  208. if(count==1)
  209. uu.pop();
  210. }
  211. }
  212. else if(n==5)
  213. {
  214. string newpass;
  215. cout << "\t\t\t Please enter a new password:";
  216. cin >> newpass;
  217. while(!uu.empty())
  218. {
  219. if(uu.front().id==newid)
  220. {
  221. f<<uu.front().id<<' '<<newpass<<' '<<uu.front().n<<' ';
  222. for(int i=0; i<uu.front().n; i++)
  223. {
  224. f<< uu.front().money[i]<<' ';
  225. }
  226. f<< uu.front().money[uu.front().n-1]<< endl;
  227. }
  228. uu.pop();
  229. count--;
  230. if(count==1)
  231. uu.pop();
  232. }
  233. cout << "\t\t\t PASSWORD RESET COMPLETE\n";
  234. }
  235. f.close();
  236. }
  237. else if(n==3)
  238. {
  239. while(!uu.empty())
  240. {
  241. if(uu.front().id==newid)
  242. {
  243. cout << "\t\t\t BALANCES:" << uu.front().money[uu.front().n-1]<<endl;
  244. }
  245. uu.pop();
  246. }
  247. }
  248. else if(n==4)
  249. {
  250. while(!uu.empty())
  251. {
  252. if(uu.front().id==newid)
  253. {
  254. cout<<"\t\t\t ID:"<<uu.front().id<<endl;
  255. for(int i=1; i<uu.front().n; i++)
  256. {
  257. cout<<"\t\t\t ";
  258. double difference=uu.front().money[i]-uu.front().money[i-1];
  259. if(difference>0)
  260. cout<<'+';
  261. cout<<difference<<endl;
  262. }
  263. if(uu.front().n==1) cout<<"\t\t\t NO RECORD";
  264. }
  265. uu.pop();
  266. }
  267. }
  268. else if(n==6)
  269. {
  270. system("cls");
  271. return 0;
  272. }
  273. return 1;
  274. }
  275. int save(string newid, string newpass)
  276. {
  277. count=0;
  278. int flog=2;
  279. fstream fi;
  280. fi.open("ios.txt",ios::in);
  281. if(!fi)
  282. {
  283. fi.open("ios.txt",ios::out);
  284. fi.close();
  285. fi.open("ios.txt",ios::in);
  286. }
  287. while(!fi.eof())
  288. {
  289. double *money=new double;
  290. user a;
  291. fi >> a.id >> a.pass >> a.n;
  292. if(a.id==newid)
  293. if(a.pass==newpass)
  294. flog=1;
  295. else
  296. return 0;
  297. for(int j =0; j<a.n; j++)
  298. {
  299. fi >> money[j];
  300. }
  301. a.money=money;
  302. uu.push(a);
  303. count++;
  304. }
  305. fi.close();
  306. return flog;
  307. }
  308. int setid(string newid,string newpass)
  309. {
  310. fstream fi("ios.txt",ios::app|ios::out);
  311. int n=1;
  312. double x=0.0;
  313. fi<< newid << ' ' << newpass << ' ' << n << ' ' << x <<endl ;
  314. fi.close();
  315. return 1;
  316. }

到这里就写完了 :) .

Bank Simulation Program银行管理系统C++ :)的更多相关文章

  1. python 银行管理系统

    这是一个使用python连接mysql的例子 涉及到类的使用 import pymysql import function as f def mysql(): db=pymysql.connect(h ...

  2. 银行管理系统[C++]

    //项目:银行管理系统 //系统实现的主要有管理,取款机管理,用户查询等功能: //*管理模块:存款.取款.开户.销户.修改信息.办卡.挂失卡; //*用户查询模块; //*取款机信息管理模块:管理员 ...

  3. c++ 银行管理系统及报告

    1.题目描写叙述: 本代码为银行管理系统,总体分为管理员模式和普通用户模式: (1)在管理员模式中能完毕 ①用户信息录入 ②改动管理员password ③改动指定账户信息 ④信息管理业务 (2)在普通 ...

  4. java实现银行管理系统

    Bank类 package First; import java.util.TreeSet; //银行类public class Bank {        private String Bankna ...

  5. python连接mysql数据库实例demo(银行管理系统数据库版)

    主函数: import adminView import os import pickle from bankFunction import BankFunction import time def ...

  6. Dark Mobile Bank之移动银行应用仿冒攻击威胁分析报告

    一.背景 据“第十五次全国信息网络安全状况暨计算机和移动终端病毒疫情调查”调查结果显示,2015年移动终端的病毒感染比例为50.46%,相对于2014年增长了18.96%,移动终端病毒感染率涨幅较大, ...

  7. 我的Java语言学习日志1_"简单的银行管理系统实现"

    设计步骤:注意:本篇代码,直接建两个类( Bank_Account.BankManage)在BankManage往里面填方法就行.是为了让和我一样自学朋友可以更快的接受.但是代码优化的空间还是很大的( ...

  8. JavaSwing开发简单的银行管理系统 附源码

    开发环境: Windows操作系统开发工具: MyEclipse/Eclipse+Jdk+mysql数据库 运行效果图:

  9. 基于Java的简单银行管理系统(MVC设计模式)

    项目导航 功能展示 项目描述 项目结构 `data` `service` `utils` `view ` 欠缺与总结 源码下载 功能展示 本系统基于命令台窗口,暂未与图形页面结合.话不多说,先上效果图 ...

随机推荐

  1. nginx开启HSTS让浏览器强制跳转HTTPS访问

    在上一篇文章中我们已经实现了本地node服务使用https访问了,看上一篇文章 效果可以看如下: 但是如果我们现在使用http来访问的话,访问不了.如下图所示: 因此我现在首先要做的是使用nginx配 ...

  2. 图片单独上传 (word)

    Word.ApplicationClass wordApp=new ApplicationClass(); object file=path; object nullobj=System.Reflec ...

  3. Ubuntu下eclipse无法识别手机驱动(以小米2S为例子)

    google官方开发向导里对Android手机已经设置了允许安装非market程序,并且处于usb调试模式,但是仍然在usb连接电脑后无法被识别的问题作了解释. 在Ubuntu Linux环境下需要添 ...

  4. jQuery动态添加元素,并提交json格式数据到后台

    参考:https://www.cnblogs.com/shj-com/p/7878727.html 下载 下载该插件的地址是:http://www.bootcdn.cn/jquery.serializ ...

  5. java如何导入Excel文件

    Java使用POI导入Excel文件,操作起来比较简单,支持xlsx格式. 下载POI资源包 从官网https://poi.apache.org/下载POI,笔者选择的是版本是3.17,下载后文件名是 ...

  6. JS常用公共方法封装

    _ooOoo_ o8888888o 88" . "88 (| -_- |) O\ = /O ____/`---'\____ .' \\| |// `. / \\||| : |||/ ...

  7. centos yum 安装mysql5.7 以及 默认root密码查看

    1.  首先更新rpm 从MySQL Yum仓库下载最新的rpm文件:http://dev.mysql.com/downloads/repo/yum/ (需要Oracle帐号以及填写一些使用信息,才能 ...

  8. agc016B - Colorful Hats(智商题)

    题意 题目链接 有$n$个人,每个人有一种颜色,第$i$个人说除了我之外有$a_i$种不同的颜色,问是否存在一组合法解 Sol 700分的题就这么神仙了么..好难啊... 先说结论吧 设$mx, mn ...

  9. Angular CLI的简单使用(2)

    刚才创建了myApp这个项目,看一下这个项目的文件结构.    项目文件概览 Angular CLI项目是做快速试验和开发企业解决方案的基础. 你首先要看的文件是README.md. 它提供了一些如何 ...

  10. 在wpf或winform关闭子窗口或对子窗口进行某个操作后刷新父窗口

    父窗口: ///<summary> ///弹出窗口  ///</summary> ///<param name="sender"></pa ...