设为首页 加入收藏

TOP

C语言 实现ATM系统(二)
2015-01-21 11:08:57 来源: 作者: 【 】 浏览:31
Tags:语言 实现 ATM 系统
printf("存款金额%d\n按任意键返回上一菜单", Count); Current_user->Money += Count; }
主程序入口

Main.cpp

#include 
  
   
#include 
   
     #include 
    
      #include 
     
       struct User *head, *Current_user; #include "User.h" #include "UI.h" #include "AccountController.h" #include "FileController.h" 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"); } } } 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') { 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(); } int main(){ startATM(); return 0; } 
     
    
   
  









首页 上一页 1 2 下一页 尾页 2/2/2
】【打印繁体】【投稿】【收藏】 【推荐】【举报】【评论】 【关闭】 【返回顶部
分享到: 
上一篇C语言动态规划-Sumsets(Hdu 2709) 下一篇C指针编程之道 ---第五次笔记

评论

帐  号: 密码: (新用户注册)
验 证 码:
表  情:
内  容: