kkk20

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
软件工程导轮 https://edu.cnblogs.com/campus/ahgc/AHPU-SE-19
作业要求 https://edu.cnblogs.com/campus/ahgc/AHPU-SE-19/homework/11477
作业目标 写一个atm管理系统,完成开户、销户、存款等功能
学号 <3190704239>

代码:

存款:

 int InputMoney(){
	int result = 100;
	char inputItem = '\0';
	int i = 0;
	system("cls");
	printf("输入金额:");
	while ((inputItem = _getch()) != '\r'){
		system("cls");
		printf("输入金额:");
		if (inputItem >= '0'&&inputItem <= '9'){
			if (result != 100){
				result *= 10;
				result += (inputItem - 48) * 100;
			}
			else {
				result = (inputItem - 48) * 100;
			}
		}
		if (result > 5000){
			printf("取款限额为5000");
			result = 0;
		}
		printf("\n%d", result);
	}
	return result;
}

查询:

`int SelectMoney(){
	int result = 100;
	char inputItem = '\0';
	char MoneyItem[][20] = { "100", "200", "500", "1000", "输入金额" };
	showMenu(MoneyItem, 5);
	/*while ((inputItem = _getch()) >='1'&&inputItem<='5')
	{	
		switch (inputItem)
		{
		case '1':
			return 100;
			break;
		case '2':
			return 200;
			break;
		case '3':
			return 500;
			break;
		case '4':
			return 1000;
			break;
		case '5':
			return InputMoney();
			break;
		default:
			printf("请输入正确选项\n");
		}
		
	}*/
	while ((inputItem = _getch()) <'1' || inputItem > '5’);//修复输入
	switch (inputItem)
	{
	case '1':
		return 100;
		break;
	case '2':
		return 200;
		break;
	case '3':
		return 500;
		break;
	case '4':
		return 1000;
		break;
	case '5':
		return InputMoney();
		break;
	default:
		printf("请输入正确选项\n");
		break;
	}
 
 
}

取存款:

bool OperationMenu(){
	char input_seletor = '\0';
	int Money = 0;
	struct User *temp = (struct User *)malloc(sizeof(struct User));
	char newPassword[7] = { '\0' };
	char confirmpassword[7] = { '\0' };
	char LoginMenu[][20] = { "取款", "存款", "查询余额", "修改密码" ,"退卡"};
	showMenu(LoginMenu, 5);
	//while ((input_seletor = _getch()) >= '1'&&input_seletor <= '5’)
	while ((inputItem = _getch()) <'1' || inputItem > '5');
	{
		switch (input_seletor)
		{
		case '1':
			Money = SelectMoney();
			WithDraw(Money);
			break;
		case '2':
			Money = SelectMoney();
			Deposit(Money);
			break;
		case '3':
			system("cls");
			printf("当前余额:%d\n按任意键返回", Current_user->Money);
			break;
		case '4':
			system("cls");
			InputPassword(Current_user->UserAccount, newPassword);
			system("cls");
			printf("再次输入以确认密码\n,按任意键继续输入");
			_getch();
			InputPassword(Current_user->UserAccount, confirmpassword);
			if (checkPassword(newPassword, confirmpassword)){
				for (int i = 0; Current_user->UserPassword[i] != '\0';i++){
					Current_user->UserPassword[i] = newPassword[i];
				}
				printf("%s  %s ",newPassword,confirmpassword);
				printf("\n密码修改成功!");
			}
			else{
				system("cls");
				printf("两次密码输入不一致");
			}
			break;
		case '5':
			return true;
			break;
		default:
			break;
		}
		_getch();
		break;
	}
	OperationMenu();
}

登录:

void startATM(){
	FILE *fp = NULL;
	char path[] = "C:\\Users\\user\\Desktop\\Account.txt";
	initdata(fp, path);//初始化数据
	int Islogin = 0;
	char input_seletor = '\0';
	char UserAccount[100] = { '\0' };
	char UserPwd[100] = { '\0' };
	char InputPwd[100] = { '\0' };
	InputAccount(UserAccount);
	//strcpy_s(UserAccount, "6210300022352527");
	if (checkAccount(UserAccount, Current_user)){
		while (Islogin<=2){
			InputPassword(UserAccount, InputPwd);
			//strcpy_s(InputPwd, "132132");
			if (checkPassword(Current_user->UserPassword, InputPwd)){
				printf("login successful\n");
				if (OperationMenu()){
					break;
				}
				Islogin = 0;
			}
			else{
				Islogin++;
				printf("password error");
			}
		}
		if (Islogin >= 2){
			system("cls");
			printf("密码三次输入错误,吞卡\n");
		}
		else{
			writeIntoFIle(fp,path);
			system("cls");
			printf("数据保存成功");
		}
	}
	_getch();
}

运行结果:



<head> <meta http-equiv=Content-Type content="text/html; charset=gb2312"> <meta name=ProgId content=Excel.Sheet> <meta name=Generator content="Microsoft Excel 14"> <link id=Main-File rel=Main-File href="../新建%20Microsoft%20Excel%20工作表.htm"> <link rel=File-List href=filelist.xml> <link rel=Stylesheet href=stylesheet.css> <style> <!--table {mso-displayed-decimal-separator:"\."; mso-displayed-thousand-separator:"\,";} @page {margin:.75in .7in .75in .7in; mso-header-margin:.3in; mso-footer-margin:.3in;} ruby {ruby-align:left;} rt {color:windowtext; font-size:9.0pt; font-weight:400; font-style:normal; text-decoration:none; font-family:宋体; mso-generic-font-family:auto; mso-font-charset:134; mso-char-type:none; display:none;} --> </style> <![if !supportTabStrip]><script language="JavaScript"> <!-- function fnUpdateTabs() { if (parent.window.g_iIEVer>=4) { if (parent.document.readyState=="complete" && parent.frames['frTabs'].document.readyState=="complete") parent.fnSetActiveSheet(0); else window.setTimeout("fnUpdateTabs();",150); } }

if (window.name!="frSheet")
window.location.replace("../新建%20Microsoft%20Excel%20工作表.htm");
else
fnUpdateTabs();
//-->

<![endif]>

</head>
psp2.1 任务内容 计划完成需要的时间(min) 实际完成需要的时间(min)
Planning 计划 10
Estimate 估计这个任务需要多少时间,并规划大致工作步骤 8 11
Development 开发 80 120
Analysis 需求分析(包括学习新技术) 12
Design Spec 生成设计文档 5
Design Review 设计复审 5 4
Coding Standard 代码规范 3
Design 具体设计 8 15
Coding 具体编码 36 20
Code Review 代码复审 5
Test 测试(自我测试,修改代码,提交修改) 8 18
Reporting 报告 9
Test Report 测试报告 3
Size Measurement 计算工作量 1 2
Postmortem & Process Improvement Plan 事后总结,并提出过程改进计划 3
</body>
posted on 2020-11-18 21:02  kkk20  阅读(159)  评论(0)    收藏  举报