名称 | 内容 |
---|---|
课程班级 | 班级连接 |
做业要求 | 做业连接 |
本人学号 | 3180405308 |
编写一个ATM管理系统,语言不限,要求应包括如下主要功能:
(1)开户,销户
(2)查询帐户余额
(3)存款
(4)取款
(5)转帐(一个帐户转到另外一个帐户)等...ios
typedef struct{ int uid;//卡号 int password;//密码 float balance; //余额 bool flag; //该帐户是否存在,存在为true }account; vector<account> base;
检查帐户是否存在,true为存在函数
//检查帐户是否存在,true为存在 bool check(account N){ bool flag = true; if (N.uid-first > base.size() || !N.flag) { printf("抱歉您所寻找的帐户并不存在,请从新输入:\n"); flag = false; } // if (!N.flag) { // printf("抱歉您所寻找的帐户已注销,请从新输入:\n"); // flag = false; // } return flag; }
//初始化 void init(account &N){ //设置卡号 int id = int(base.size()); N.uid = first+id; //六位卡号 printf("您的卡号为: %d \n",N.uid); //设置密码 printf("请设置您的密码:\n"); int psw = 0; scanf("%d",&psw); N.password = psw; //帐户密码 //初始化余额 N.balance = 0; //帐户余额 //将帐户标记为存在,没有被注销 N.flag = true; }
//开户 void create(){ account N; init(N); base.push_back(N); }
//销户 void cancel(){ printf("请输入您须要删除的帐号卡号:\n"); int id = 0; scanf("%d",&id); while (check(base[id-first]) == false) { scanf("%d",&id); } printf("请输入该 %d 帐号的密码:\n",id); int psw = 0; scanf("%d",&psw); while (psw != base[id-first].password) { printf("抱歉,您输入的密码并不正确,请从新输入:\n"); scanf("%d",&psw); } printf("您是否确认注销该帐户?\t 输入1为确认注销,输入0为不注销\n"); int choice = 0; cin>>choice; if (choice == 1) { base[id-first].flag = false; //flag标记为帐户不存在 } else { printf("您已取消本次注销行为\n"); } }
//查询余额 void enquire(){ printf("请输入您的帐户卡号:\n"); int id = 0; scanf("%d",&id); while (check(base[id-first]) == false) { scanf("%d",&id); } if (base[id-first].balance == 0) { printf("很抱歉,您当前并未有任何存款\n"); } else { printf("您的余额为: %f ¥\n",base[id-first].balance); } }
//存款 void deposit(){ printf("请输入您的帐户卡号:\n"); int id = 0; scanf("%d",&id); while (check(base[id-first]) == false) { scanf("%d",&id); } float input = 0; printf("请输入您要存入的金额数目\n"); scanf("%f",&input); base[id-first].balance += input; printf("您的余额为: %f ¥\n",base[id-first].balance); }
//取款 void withdraw(){ printf("请输入您的帐户卡号:\n"); int id = 0; scanf("%d",&id); while (check(base[id-first]) == false) { scanf("%d",&id); } float input = 0; printf("请输入您要取出的金额数目\n"); scanf("%f",&input); if (base[id-first].balance < input) { printf("抱歉,您的存款不足,不能取出\n"); } else { base[id-first].balance -= input; printf("您的余额为: %f ¥\n",base[id-first].balance); } }
//转帐 void transfer(){ printf("请输入您的帐户卡号:\n"); int oid = 0; scanf("%d",&oid); while (check(base[oid-first]) == false) { scanf("%d",&oid); } printf("请输入您所要转入的帐户卡号:\n"); int iid = 0; scanf("%d",&iid); while (check(base[oid-first]) == false) { scanf("%d",&oid); } float input = 0; printf("请输入您要转出的金额数目\n"); scanf("%f",&input); if (base[oid-first].balance < input) { printf("抱歉,您的存款不足,不能转出\n"); } else { base[oid-first].balance -= input; base[iid-first].balance += input; printf("您的余额为: %f ¥\n",base[oid-first].balance); printf("对方余额为: %f ¥\n",base[iid-first].balance); } }
//菜单 void menu(){ int end = 0; //是否结束,0记为不结束 do { printf("请选择您须要进行的操做:\n1.开户\t2.销户\n3.查询当前余额\n4.存款\t5.取款\n6.转帐\t0.退出\n"); int choose = 0; scanf("%d",&choose); switch (choose) { case 0: printf("Bye~\n"); exit(0); case 1: create(); break; case 2: cancel(); break; case 3: enquire(); break; case 4: deposit(); break; case 5: withdraw(); break; case 6: transfer(); break; default: break; } printf("请问您是否须要继续进行其余操做?输入1继续进行其余操做,输入0则退出\n"); scanf("%d",&end); } while (end); }
psp | 任务内容 | 计划完成须要的时间(min) | 实际完成须要的时间(min) |
---|---|---|---|
Planning | 计划 | 5 | 3 |
Estimate | 估计这个任务须要多少时间,并规划大体工做步骤 | 5 | 5 |
Development | 开发 | 300 | 300 |
Analysis | 需求分析(包括学习新技术) | 15 | 45 |
Design Spec | 生成设计文档 | 5 | 20 |
Design Review | 设计复审 | 5 | 5 |
Coding Standard | 代码规范 | 3 | 3 |
Design | 具体设计 | 10 | 12 |
Coding | 具体编码 | 200 | 200 |
Code Review | 代码复审 | 10 | 20 |
Test | 测试(自我测试,修改代码,提交修改) | 10 | 60 |
Reporting | 报告 | 5 | 5 |
Test Report | 测试报告 | 5 | 5 |
Size Measurement | 计算工做量 | 20 | 30 |
Postmortem & Process Improvement Plan | 过后总结,并提出过程改进计划 | 20 | 20 |
// // main.cpp // ATM管理系统 // // Created by Chen on 2020/11/8. // Copyright © 2020 xxc. All rights reserved. // //编写一个ATM管理系统,语言不限,要求应包括如下主要功能: //(1)开户,销户 //(2)查询帐户余额 //(3)存款 //(4)取款 //(5)转帐(一个帐户转到另外一个帐户)等... #include <iostream> #include <vector> #define first 100000 using namespace std; typedef struct{ int uid;//卡号 int password;//密码 float balance; //余额 bool flag; //该帐户是否存在,存在为true }account; vector<account> base; //检查帐户是否存在,true为存在 bool check(account N){ bool flag = true; if (N.uid-first > base.size() || !N.flag) { printf("抱歉您所寻找的帐户并不存在,请从新输入:\n"); flag = false; } // if (!N.flag) { // printf("抱歉您所寻找的帐户已注销,请从新输入:\n"); // flag = false; // } return flag; } //初始化 void init(account &N){ //设置卡号 int id = int(base.size()); N.uid = first+id; //六位卡号 printf("您的卡号为: %d \n",N.uid); //设置密码 printf("请设置您的密码:\n"); int psw = 0; scanf("%d",&psw); N.password = psw; //帐户密码 //初始化余额 N.balance = 0; //帐户余额 //将帐户标记为存在,没有被注销 N.flag = true; } //开户 void create(){ account N; init(N); base.push_back(N); } //销户 void cancel(){ printf("请输入您须要删除的帐号卡号:\n"); int id = 0; scanf("%d",&id); while (check(base[id-first]) == false) { scanf("%d",&id); } printf("请输入该 %d 帐号的密码:\n",id); int psw = 0; scanf("%d",&psw); while (psw != base[id-first].password) { printf("抱歉,您输入的密码并不正确,请从新输入:\n"); scanf("%d",&psw); } printf("您是否确认注销该帐户?\t 输入1为确认注销,输入0为不注销\n"); int choice = 0; cin>>choice; if (choice == 1) { base[id-first].flag = false; //flag标记为帐户不存在 } else { printf("您已取消本次注销行为\n"); } } //查询余额 void enquire(){ printf("请输入您的帐户卡号:\n"); int id = 0; scanf("%d",&id); while (check(base[id-first]) == false) { scanf("%d",&id); } if (base[id-first].balance == 0) { printf("很抱歉,您当前并未有任何存款\n"); } else { printf("您的余额为: %f ¥\n",base[id-first].balance); } } //存款 void deposit(){ printf("请输入您的帐户卡号:\n"); int id = 0; scanf("%d",&id); while (check(base[id-first]) == false) { scanf("%d",&id); } float input = 0; printf("请输入您要存入的金额数目\n"); scanf("%f",&input); base[id-first].balance += input; printf("您的余额为: %f ¥\n",base[id-first].balance); } //取款 void withdraw(){ printf("请输入您的帐户卡号:\n"); int id = 0; scanf("%d",&id); while (check(base[id-first]) == false) { scanf("%d",&id); } float input = 0; printf("请输入您要取出的金额数目\n"); scanf("%f",&input); if (base[id-first].balance < input) { printf("抱歉,您的存款不足,不能取出\n"); } else { base[id-first].balance -= input; printf("您的余额为: %f ¥\n",base[id-first].balance); } } //转帐 void transfer(){ printf("请输入您的帐户卡号:\n"); int oid = 0; scanf("%d",&oid); while (check(base[oid-first]) == false) { scanf("%d",&oid); } printf("请输入您所要转入的帐户卡号:\n"); int iid = 0; scanf("%d",&iid); while (check(base[oid-first]) == false) { scanf("%d",&oid); } float input = 0; printf("请输入您要转出的金额数目\n"); scanf("%f",&input); if (base[oid-first].balance < input) { printf("抱歉,您的存款不足,不能转出\n"); } else { base[oid-first].balance -= input; base[iid-first].balance += input; printf("您的余额为: %f ¥\n",base[oid-first].balance); printf("对方余额为: %f ¥\n",base[iid-first].balance); } } //菜单 void menu(){ int end = 0; //是否结束,0记为不结束 do { printf("请选择您须要进行的操做:\n1.开户\t2.销户\n3.查询当前余额\n4.存款\t5.取款\n6.转帐\t0.退出\n"); int choose = 0; scanf("%d",&choose); switch (choose) { case 0: printf("Bye~\n"); exit(0); case 1: create(); break; case 2: cancel(); break; case 3: enquire(); break; case 4: deposit(); break; case 5: withdraw(); break; case 6: transfer(); break; default: break; } printf("请问您是否须要继续进行其余操做?输入1继续进行其余操做,输入0则退出\n"); scanf("%d",&end); } while (end); } int main(int argc, const char * argv[]) { menu(); return 0; }