ATM自动取款机C语言源代码

合集下载

C语言ATM自动存取款机全套代码

C语言ATM自动存取款机全套代码

C语言ATM自动存取款机全套代码#include#include#include#include#include#define N 6char b[N]={'8','8','8','8','8','8'};//存放密码int money=5000;int securitytime=3;void Login();void JieMian();void SaveMoney();void GetMoney();void Query();void Return();//密码验证函数,验证成功返回1,否则返回0void Login(){char a[20],ch; //用户登录密码,用以验证int i=0,n=1,k;printf("\n\t\t欢迎使用ICBC ATM自动存取款机\n"); printf("\n请输入密码:");for(n=1;n<=5;n++){while((a[i]=getch())!=13){ i=i+1;printf("*");//将用户输入的密码以*显示}for(k=0;k<6;k++)if(a[k]!=b[k]) break;if (k==6){printf("\n密码正确,请继续!!\n");JieMian(); }else//printf("\n密码错误,请重新输入:\n");printf("\n密码错误,您还有%d次机会,请重新输入:\n",5-n);}printf("\n您已经输入5次错误,您的卡将被没收,请去相关网点办理!\n");exit(1);}// 界面设计void JieMian(){int SelectKey;//system("cls");//清屏幕函数while(1){puts("\n= = = = = = = = = = = = = = = =");puts("| 请选择相应功能: |");puts("| 1. 修改密码PassWord |");puts("| 2. 查询功能Query |");puts("| 3. 取款功能Get Money |");puts("| 4. 存款功能Save Money | ");puts("| 5. 转帐功能Trans Money | ");puts("| 6. 退出功能Return | ");puts("\n= = = = = = = = = = = = = = = = ");printf("\n请选择功能:");scanf("%d",&SelectKey);switch(SelectKey){ case 1:printf("\n修改密码功能\n");//PassWord();break;case 2:printf("\n查询功能\n");Query();break;case 3:printf("\n取款功能\n");GetMoney();break;case 4:printf("\n存款功能\n");SaveMoney();break;case 5:printf("\n转帐功能\n");//Trans();break;case 6:printf("\n退出功能\n");Return();break;}}}/*Query查询功能*/void Query(){system("cls");puts("================================== ==");printf("| Your Query balance is $%ld |\n",money);puts("| Press any key to return... |");puts("================================== ==");return;}/*GetMoney取钱功能*/void GetMoney(){char GetMoney;char kahao[20];long y;//输入待转入的相关信息//卡号,姓名do{puts("=================================");puts("| Please select GetMoney: |");puts("| 1. $100 |");puts("| 2. $200 |");puts("| 3. other |");puts("| 4. Return |");puts("=================================");GetMoney = getch();}while(GetMoney!='1'&&GetMoney!='2'&&GetMoney!='3' && GetMoney!='4');switch(GetMoney){case '1':system("cls");if(money>100){puts("================================== =========");puts("| Your GetMoney is $100,Thank you! |");puts("| Press any key to return... |");puts("===========================================");money=money-100;printf("\n您的余额为%d",money);}else printf("\n您的余额不足!");getch();break;case '2':system("cls");if(money>200){puts("================================== ======");puts("| Your GetMoney is $200,Thank you! |");puts("| Press any key to return... |");puts("================================== ======");money=money-200;printf("\n 您的余额为%d",money);}else printf("\n您的余额不足!");getch();break;case '3':system("cls");printf("please get some money:");scanf("%ld",&y);if(money>y){money=money-y;printf("\n您的余额为%d",money);}else{printf("\n您的余额不足!");printf("\n您的余额为%d",money);}getch();break;case '4': break;}return;}/*SaveMoney存钱功能*/void SaveMoney(){ char SaveMoney;long y;do{system("cls");puts("================================== ========");puts("| Please select Save Money: |");puts("| 1. $100 |");puts("| 2. $500 |");puts("| 3. $1000 |");puts("| 4. other |");puts("| 5. Return |");puts("================================== ========");SaveMoney = getch();}while(SaveMoney!='1'&&SaveMoney!='2'&& SaveMoney!='3'&&SaveMoney!='4'&&SaveMoney!='5');switch(SaveMoney){ case '1':{{system("cls");puts("================================== =========");puts("| Your save money is $100,Thank you! |");puts("| Press any key to return... |");puts("================================== ========");}money=money+100;printf("\n您的余额为%d",money);getch();}break;case '2':{system("cls");puts("================================== ============");puts("| Your Save Money is $500,Thank you! |");puts("| Press any key to return... |");puts("================================== ============");money=money+500;printf("\n您的余额为%d",money);getch();}break;case '3':{system("cls");puts("============================================");puts("| Your Save Money is $1000,Thank you! |");puts("| Press any key to return... |");puts("================================== ==========");money=money+1000;printf("\n您的余额为%d",money);getch();}break;case '4':{system("cls");puts("================================== ===========");puts("| Your Save some Money,Thank you! |");puts("| Press any key to return... |");puts("================================== ===========");puts("please save some money:");scanf("%ld",&y);if(y%100!=0)printf("该存款机只能处理整百的操作,请核查!!");else{money=money+y;printf("\n您的余额为%d",money);}getch();}break;case '5':break; }return;}/*Return,退出功能*/void Return(){system("cls");puts("================================== ==");puts("| Thank you for your using! |");puts("| RETURN! |");puts("================================== ==");exit(1);}//主函数int main(){Login();}上一页下一页。

C语言ATM机代码

C语言ATM机代码

#include<stdio.h>#include<stdlib.h>#include<direct.h>#include<string.h>#include<conio.h>typedef struct /*定义结构体*/{int cid /*账号*/;char name[20] /*姓名*/;char pws[20] /*密码*/;int money /*金额*/;} CAT;void create();void service();int GetNewId();void PutNewId();int submit();void get(int,int);void save(int,int);int chaxun(int);void transfer(int);void ChPsw(int);void load();void rload();void main(){int chose/*首页菜单选择*/;printf("\n\n\n\n\n");printf(" ******** 欢迎光临******** \n");printf(" * * \n");printf(" * 这是JJ银行自助系统* \n");printf(" * * \n");printf(" * 欢迎您的使用* \n");printf(" * *\n");printf(" * 人民币* \n");printf(" * * \n");printf(" * 因您而精彩!!! * \n");printf(" * * \n");printf(" ********** ********** \n\n");printf(" 系统正在加载");load();system("cls");TT: //主界面system("cls");printf("\n");printf("****************************欢迎使用JJ自助银行系统!***************************\n");printf("**\n");printf("* 1.开户*\n");printf("* 2.服务*\n");printf("* 3.取卡*\n");printf("**\n");printf("******************************************************************\n");printf("\n");printf("请选择您要交易的类型:");scanf("%d",&chose);printf("\n");while(!(chose>=1 && chose<=3)) //判断选择是否正确{printf("您选择的类型不正确,请重新选择:");scanf(" %d",&chose);printf("\n");if(chose>=1 && chose<=3)break;}switch(chose) //功能菜单选择{case 1: //开户create();goto TT;break;case 2:service();goto TT;break;case 3:printf("请取回您的磁卡!\n");break;}printf("\n");system("pause");}void create(){CAT a/*用户信息*/;int i/*数组变量控制*/;char spsw[20];system("cls");printf("\n");printf("**************************** 这里是开户菜单*****************************\n\n");a.cid=GetNewId();printf("开户账号为: %d \n\n",a.cid);printf("请设置账号信息...\n\n");printf("请设置姓名: ");scanf("%s",);printf("请设置账号密码:");i=0;while((a.pws[i]=getch())!=13) //设置密码以*号显示{putchar('*');i++;}a.pws[i]='\0';printf("\n请输入确认密码:");i=0;while((spsw[i]=getch())!=13){putchar('*');i++;}spsw[i]='\0';while(strcmp(a.pws,spsw)!=0){printf("\n确认密码错误请重新输入:");i=0;while((spsw[i]=getch())!=13){putchar('*');i++;}spsw[i]='\0';}printf("\n请输入开户金额:");scanf("%d",&a.money);printf("\n\n");printf("账号为:%d\n",a.cid); //输出设置账号printf("姓名为:%s\n",);printf("密码为:%s\n",a.pws); //输出设置密码printf("余额为:%d",a.money);printf("\n\n");printf("开户成功!\n");printf("请妥善保管您的账号和密码!\n\n");PutNewId(a);printf("按任意键返回。

(经典版)C语言版ATM银行取款机系统完整源代码程序设计基础实训II文档.doc

(经典版)C语言版ATM银行取款机系统完整源代码程序设计基础实训II文档.doc

2012年6月项目实训任务书课程名称:程序设计基础实训II课程编码:JX课程类别:专业基础必修课学分数:2学时数:32开课学期:2实训题目:ATM存取款系统的改进与完善一、已知技术参数和设计要求:银行ATM存取款系统业务描述如下:银行ATM存取款系统能为用户提供存款、取款、查询、转账和修改密码的功能。

为了模拟真实的ATM业务环境,本系统必须实现存款、取款、查询、转账、修改密码以及开户的功能。

用户通过开户业务在本系统开立银行账户,之后可以通过该银行账户登陆ATM系统,在系统中实现存款、取款、查询账户信息、修改密码的操作。

本系统各个业务有如下注意点:(1)登陆系统用户登陆之前,必须在登陆界面输入其银行账户,通过其正确输入的银行账户登陆系统。

(2)开户业务要使用本系统必须首先执行开户业务开立新的银行账户,并且将此新开的银行存储于文件当中。

同时,系统以身份证号码作为开户的充分条件,即一个身份证号码只能开立一次银行账户。

(3)存款业务客户登陆系统后,选择存款业务,即可以将输入的存款金额存入相应的账户。

(4)取款业务客户登陆系统后,选择取款业务,即可以将输入的取款金额从相应的银行账户取出,但是取款金额必须大于目前的账户余额。

(5)查询业务客户登陆系统后,可以选择查询业务,查询账户余额。

(6)转账业务客户登陆系统后,可以选择转账业务,进行转账。

注意的是转账的目的账户必须是本系统已经存在的银行账户。

(7)修改密码客户登陆系统后,可以选择修改密码业务,进行密码修改。

二、各阶段具体要求:1、系统总体设计阶段(1)根据需求分析划分功能模块(2)分析并设计各个功能模块之间的关系(3)对于各个功能模块,设计相应的数据结构(必须使用链表完成全部功能)(4)设计相应的算法(必须包括排序和检索功能,且基于链表进行排序和检索)2、详细设计阶段(1)对于每个功能模块,应划分成操作层和数据层(2)对于每个操作层,应尽量考虑用户操作的简单,便捷(3)对于每个数据层,必须使用链表进行管理(4)在用链表进行管理时,必须用到链表检索和排序(5)对于数据层的操作完的数据必须保存到文件中(包括文件读、写操作)3、编码实现阶段(1)完成代码编写(2)要求代码编写规范(不得使用全局变量、所有功能模块必须使用函数封装主函数main()的行数不得超过代码总长度的25%)(3)代码必须有相应的注释(注释行数不得少于代码的10%,函数功能、变量名、算法、重要的循环、分支都必须用注释说明)4、系统测试阶段(1)完成功能调试(2)要求完成必要的测试工作5、交付实施阶段(1)提交可正常执行的系统,程序代码(2)撰写项目实训报告书(3)要求按照文档书写规范,严格地书写文档(4)注意:不允许使用代码、图片和表格填充报告空间。

用c语言编写的一个ATM取款机程序

用c语言编写的一个ATM取款机程序

⽤c语⾔编写的⼀个ATM取款机程序学了⼀个多星期的c语⾔了,⽼师布置来了作业,⽤C编写个ATM机的模拟程序,客户界⾯有,取款,2存款,3转账,4退出。

并且要求输⼊错误后,有三次机会重输,定义输⼊密码hellowold,⽤switch分⽀。

#include<stdio.h>#include<string.h>#define key "hellowold"//定义密码#define zhanghu "123456789"#define line "==================\n"int num;//选择类型char arr[20];//定义数组char password[20];//定义数组int money;//取款⾦额int i=0;int main(){printf(line);printf("\t1取款\n");printf("\t2存款\n");printf("\t3转账\n");printf("\t4退出\n");printf(line);printf("请选择操作类型: \n");scanf("%d",&num);switch(num){case1:{ do{printf("请输⼊密码:\n");scanf("%s",&password);if(strcmp(key,password)==0){printf("请输⼊取款⾦额:\n");scanf("%d",&money);printf("请取⾛你的%d⽑爷爷",money);break;}else{printf("密码输⼊错误");}i++;}while((strcmp(key,password)!=0)&&i<=2);}}第⼆步存款,定义账号#include<stdio.h>#include<string.h>#define key "hellowold"//定义密码#define zhanghu "#define other "ni de mao ye ye"#define line "==================\n"int num;//选择类型char arr[20];//定义数组char password[20];//定义数组char others[20];int money;//取款⾦额int num2;//存款⾦额int i=0;int main(){printf(line);printf("\t1取款\n");printf("\t2存款\n");printf("\t3转账\n");printf("\t4退出\n");printf(line);printf("请选择操作类型: \n");scanf("%d",&num);switch(num){case1:{ do{printf("请输⼊密码:\n");scanf("%s",&password);if(strcmp(key,password)==0){printf("请输⼊取款⾦额:\n");scanf("%d",&money);printf("请取⾛你的%d⽑爷爷",money);break;}else{printf("密码输⼊错误");}i++;}while((strcmp(key,password)!=0)&&i<=2);break;}今天先变到这⾥吧,作业还多着了,排版不是很好看,就将就这看吧。

C++银行自动取款机源程序代码

C++银行自动取款机源程序代码

//consumer.h#include <iostream>#include <string>using namespace std;class consumer{public:void initConsumer(string ,string ,string ,float);//初始化string GetName();string GetID();string GetPassword();float GetMoney();void SetName(string N);void SetID(string I);void SetPassword(string Pw);void SetMoney(float M);void ChangPassword();//更改密码void ShowMe();//显示账户信息void FetchMoney();//取款private:string Password;//用户密码string Name;//用户姓名string ID;//用户卡号float Money;//用户余额};//bank.h#include <iostream>#include <string>#include"consumer.h"using namespace std;class bank{public:void Welcome();//欢迎界面void ExitSystem();//退出系统void Menu();//选择菜单int Seek(string);//查找卡号void initConsumer(int i,string N,string I,string Pw,float M); string GetName();string GetID();string GetPassword();float GetMoney();//void SetName(string N);//void SetID(string I);//void SetPassword(string Pw);//void SetMoney(float M);void ChangPassword();//更改密码void ShowMe();//显示账户信息void FetchMoney();//取款private:int i;consumer cs[50];};//consumer.cpp#include "consumer.h"void consumer::initConsumer(string N,string I,string Pw,float M) {Name=N;ID=I;Password=Pw;Money=M;}string consumer::GetName(){return Name;}string consumer::GetID(){return ID;}string consumer::GetPassword(){return Password;}float consumer::GetMoney(){return Money;}void consumer::ChangPassword()//更改密码{cout<<"******欢迎进入更改密码界面******"<<endl;string p;cout<<"请输入原密码";cin>>p;string q,w;if(p==Password){cout<<"请输入您的新密码:";cin>>q;cout<<"请再次输入您的新密码:";cin>>w;cout<<w<<endl;if(w==q){Password=q;cout<<"密码修改成功"<<endl;}elsecout<<"您两次输入的密码不一致,修改失败!"<<endl;}elsecout<<"您输入的密码错误!"<<endl;}void consumer::FetchMoney() //取款{float a;cout << "请输入取款金额:"<<endl;cin>>a;while(a <= 0){cout<<"输入金额有误,请您重新输入正确的金额:"<<endl;cin>>a;}if(Money-a<0)cout << "对不起,你的余额不足!" <<endl;else{cout <<"正在取款中,请稍候......"<<endl;Money= Money- a;cout <<"交易成功!"<<endl;}}void consumer::ShowMe() //显示账户信息{cout<<"**********************************"<<endl;cout<<"当前账号信息:"<<endl;cout<<"用户姓名:"<<Name<< endl;cout<<"银行卡号: "<<ID<< endl;cout<<"卡内余额: "<<Money<<endl;cout<<"**********************************"<<endl;}//bank.cpp#include "bank.h"void bank::Welcome() //欢迎界面{cout<<"************欢迎使用哆啦A梦自动取款机************"<<endl;cout<<"请输入卡号:"<<endl;string id;int flag=-1;cin>>id;flag=Seek(id);}void bank::ExitSystem() //退出系统{cout<<"*************谢谢您的使用***************"<<endl;cout<<"********请取卡,收好您的银行卡**********"<<endl;exit(0);}void bank::Menu()//选择菜单{int n;do{cout<<"********************"<<endl;cout<<"请输入相应的操作序号"<<endl;cout<<"1 修改密码"<<endl;cout<<"2 取款"<<endl;cout<<"3 显示余额"<<endl;cout<<"4 退出系统"<<endl;cout<<"********************"<<endl;cin>>n;while(n<1||n>4){cout<<"操作错误,请输入正确的操作序号!"<<endl;cin>>n;}switch(n){case 1: ChangPassword();break;case 2: FetchMoney();break;case 3: ShowMe();break;case 4: ExitSystem();break;}}while(true);}int bank::Seek(string id){for(int j=0;j<50;j++){if(id==cs[j].GetID()){i=j;break;}}if(j>=50){i=-1;}return i;}void bank::initConsumer(int i,string N,string I,string Pw,float M)//初始化{cs[i].initConsumer(N,I,Pw,M);}string bank::GetName(){return cs[i].GetName();}string bank::GetID(){return cs[i].GetID();}string bank::GetPassword(){return cs[i].GetPassword();}float bank::GetMoney(){return cs[i].GetMoney();}void bank::ChangPassword()//更改密码{cs[i].ChangPassword();}void bank::ShowMe()//显示账户信息{cs[i].ShowMe();}void bank::FetchMoney()//取款{cs[i].FetchMoney();}//main.cpp#include <iostream>#include <string>#include "bank.h"using namespace std;int main(){bank b;b.initConsumer(0,"林","1","111111",1000);b.initConsumer(1,"王","2","222222",2000);b.initConsumer(2,"吴","3","333333",3000);b.initConsumer(3,"梁","4","444444",4000);b.Welcome();b.Menu();return 0;}。

C语言模拟ATM机的编写程序

C语言模拟ATM机的编写程序

C语言模拟ATM机的编写程序#include <stdio.h>void main(){long int a,b,c,d,e,f,g,k,l,m,n,o,p,h;n=0;h=10000;k=123456;loop0: printf("\t\t\t欢迎使用中国邮政ATM取款机!\n\n");printf("请插入你的银行卡,并输入你的密码,三次密码输入错误,将终止程序:\n");scanf("%ld",&l);if(k==l){loop1: printf("请输入你选择的操作类型:\n");printf("请输入0-4进行选择:\n");printf("1:<转账>\t2:<查询>\t3:<取款>\t4:<修改密码>\t0:<取卡>\n");scanf("%ld",&a);switch(a){case 1: printf("请输入转账账号:\n");scanf("%d",&o);printf("请输入你需要转账的金额:\n");scanf("%d",&p);printf("请输入你选择的操作类型:\n");printf("请输入0或1进行选择:\n");printf("1:<确认>\t0:<返回>\n");h=10000-p;scanf("%ld",&b);switch(b){case 1:printf("\n转账%d元人民币成功!\n\n",p);goto loop1;break;case 0:goto loop1;break;default :printf("\n无此操作项!\n\n");goto loop1;}break;loop4:case 2:printf("请输入你选择的操作类型:\n");printf("请输入0-2进行选择:\n");printf("1:<查询余额>\t2:<查询明细>\t0:<返回>\n");scanf("%ld",&c);switch(c){case 1:printf("\n你的余额为:%5d\n\n",h);goto loop1;break;case 2:printf("\n你的账单为:******。

c语言atm机编程代码

c语言atm机编程代码

c语言atm机编程代码下面是一个简单的C语言ATM机编程代码示例:#include <stdio.h>// ATM机账户结构体typedef struct {int account_number;float balance;} Account;// 初始化账户信息void init_account(Account *account, int acc_no, float bal) { account->account_number = acc_no;account->balance = bal;}// 存款void deposit(Account *account, float amount) {account->balance += amount;}// 取款void withdraw(Account *account, float amount) {if (account->balance >= amount) {account->balance -= amount;} else {printf("余额不足!\n");}}// 查询余额void check_balance(Account *account) {printf("当前余额:%.2f\n", account->balance); }// 主函数int main() {Account my_account;int choice;float amount;// 初始化账户信息init_account(&my_account, 123456789, 5000.0);// ATM机操作菜单printf("欢迎使用ATM机!\n");printf("请选择操作:\n");printf("1. 存款\n");printf("2. 取款\n");printf("3. 查询余额\n");printf("0. 退出\n");do {printf("请输入操作代码:");scanf("%d", &choice);switch (choice) {case 1:printf("请输入存款金额:");scanf("%f", &amount);deposit(&my_account, amount); break;case 2:printf("请输入取款金额:");scanf("%f", &amount);withdraw(&my_account, amount); break;case 3:check_balance(&my_account);break;case 0:printf("退出程序!\n");break;default:printf("无效的操作!\n");}} while (choice != 0);return 0;}。

自动取款机源代码(C and C++)

自动取款机源代码(C and C++)

#include <iostream.h>
#include <fstream.h>
#include <stdio.h>
#include <time.h>
#include <string.h>
#include <windows.h>
struct Acount{
char name[20];
if(x>0)
cout<<"| 交易类型 | 现金存款 |"<<endl;
else
{ x=-x;
cout<<"| 交易类型 | 现金取款 |"<<endl;
{
int n;
fstream file("账号.dat",ios::binary|ios::nocreate|ios::in|ios::out);
if(!file)
{
cout<<"不能打开此文件"<<endl;
return 0;
} Βιβλιοθήκη n=0; cout<<"| 交易批号 | 198447 |"<<endl;
cout<<"| 时间/日期 | "<<time<<" |"<<endl;
cout<<"+-----------------------------------------------------------------+"<<endl;

c语言银行自动存取款机模拟

c语言银行自动存取款机模拟

C语言银行自动存取款机模拟介绍本文档将介绍如何使用C语言编写一个简单的银行自动存取款机模拟程序。

该程序可以模拟银行客户进行存款和取款操作,并实时更新账户余额。

功能此银行自动存取款机模拟程序具有以下功能:•登录功能:用户可以输入账号和密码进行登录。

•存款功能:用户可以输入存款金额进行存款,存款成功后会更新账户余额。

•取款功能:用户可以输入取款金额进行取款,取款成功后会更新账户余额。

•查询余额功能:用户可以查看账户余额。

•退出功能:用户可以选择退出程序。

程序设计数据结构在程序中,需要定义一个结构体来表示银行客户的账户信息。

每个账户包含账号、密码和余额:struct Account {int accountNumber;char password[20];double balance;};登录功能首先,用户需要输入账号和密码进行登录。

可以定义一个函数来实现登录功能:int login(struct Account *accounts, int numAccounts, int accountNumber, char *password) {for (int i = 0; i < numAccounts; i++) {if (accounts[i].accountNumber == accountNumber && strcmp(accounts[i].password, password) == 0) {return i; // 返回账号在数组中的索引}}return -1; // 登录失败,返回-1}存款和取款功能存款和取款功能可以分别定义两个函数来实现。

存款函数会增加账户余额,取款函数会减少账户余额。

```c void deposit(struct Account *account, double amount) { account->balance += amount; }void withdraw(struct Account *account, double amount) { if (account->balance >= amount) { account->balance -= amount; printf(。

C语言实现ATM系统程序的完整代码

C语言实现ATM系统程序的完整代码

C语⾔实现ATM系统程序的完整代码实现效果如图:代码如下:#include<stdio.h>#include<string.h>#include<conio.h>#include<stdlib.h>//开户信息typedef struct _Person{char name[20];char account[20];char password[7];float money;}Person;//结点typedef struct _Node{Person P; //客户struct _Node* next;}Node;Node* HeadNode = NULL;//链表头/*----------------函数--------------------*/void Login();void Menu();void Register();void LoginMenu(Node* pNode);void FindAccount(Node* pNode);void DrawMoney(Node* pNode);void Deposit(Node* pNode);void Transfer(Node* pNode);void LoginMenu(Node* pNode);//主菜单void Menu(){printf("\n\t\t\t欢迎进⼊ATM银⾏管理系统\n");printf("\t\t 1. 注册\n");printf("\t\t 2. 登录\n");printf("\t\t 3. 系统帮助\n");printf("\t\t 4. 查询账号\n");printf("\t\t 5. 退出\n");}//注册void Register(){Node* NewNode = (Node*)malloc(sizeof(Node));NewNode->next = NULL;NewNode->P.money = 0;printf("请输⼊您的名字:");scanf("%s", NewNode->);printf("请输⼊您的密码:");scanf("%s", NewNode->P.password);char Password[7];printf("请再次输⼊您的密码:");scanf("%s", Password);for (int i = 1; i < 4; i++){if (strcmp(NewNode->P.password, Password) != 0){printf("您输⼊的密码有误,还有%d次机会.\n", 3 - i);printf("请再次输⼊您的密码:");scanf("%s", Password);}else{srand((unsigned int)time(NULL));sprintf(NewNode->P.account, "%d%d%d%d%d", rand() % 9000 + 1000, rand() % 9000 + 1000, rand() % 9000 + 1000, rand() % 9000 + 1000, rand() % 900 + 100);//头插法if (HeadNode == NULL){HeadNode = NewNode;}else{NewNode->next = HeadNode;HeadNode = NewNode;}printf("\n\n\n\n\t\t\t\t恭喜你已经成功注册账户,以下是您的账户信息.\n");printf("\t\t\t\t姓名:%s\n", NewNode->);printf("\t\t\t\t账户:%s\n", NewNode->P.account);printf("\t\t\t\t余额:%.2f\n", NewNode->P.money);getch();return 1;}}printf("您的账号已被锁定,请稍后再试.");return 1;}//取款void DrawMoney(Node* pNode){Node* mNode = pNode;float Money = 0;printf("欢迎进⼊ATM银⾏管理系统\n");printf("请选择你取款⾦额\n");printf("100\t\t2000\n");printf("500\t\t5000\n");printf("10000\t\t其他⾦额\n");scanf("%f", &Money);mNode->P.money = mNode->P.money - Money;return mNode;}//存款void Deposit(Node* pNode){Node* mNode = pNode;float Money = 0;printf("请存取您的⾦额:");scanf("%f", &Money);mNode->P.money = mNode->P.money + Money;return mNode;}//转账void Transfer(Node* pNode){Node* TNode = HeadNode;char Account[20];printf("请输⼊转账的号码:");scanf("%s", Account);while (TNode != NULL){if (strcmp(TNode->P.account, Account) != 0){TNode = TNode->next;continue;}else{float Money = 0;printf("请输⼊您要转账的⾦额:");printf("100\t\t2000\n");printf("500\t\t5000\n");printf("10000\t\t其他⾦额\n");scanf("%f", &Money);TNode->P.money = TNode->P.money + Money;pNode->P.money = pNode->P.money - Money;return 1;}}return 1;}//登录菜单void LoginMenu(Node * pNode){while (1){printf("欢迎进⼊ATM银⾏管理系统\n");printf("请选择以下服务:\n");printf("1.取款\t\t2.查询\n");printf("3.存款\t\t4.转账\n");printf("5.修改密码\t6.退出\n");char ch = getch();switch (ch){case '1':DrawMoney(pNode);break;case '2':printf("您的账户余额为:%.2f", pNode->P.money);getch();break;case '3':Deposit(pNode);break;case '4':Transfer(pNode);break;case '5':break;case '6':return 0;break;default:break;}system("cls");}}//登录void Login(){system("cls");Node* pNode = HeadNode;char P_account[20];char P_password[7];printf("请输⼊您的卡号:");scanf("%s", P_account);while (pNode != NULL){if (strcmp(P_account,pNode->P.account) != 0){pNode = pNode->next;continue;}else{for (int i = 1; i < 4; i++){printf("请输⼊您的密码:");scanf("%s", P_password);if (strcmp(P_password, pNode->P.password) != 0){printf("您输⼊的密码有误,还有%d次机会.\n", 3 - i);}else{system("cls");LoginMenu(pNode);return 1;}}printf("\n对不起,您输⼊的密码有误,请重新登录.\n");system("pause");return 1;}}return 1;}//系统帮助信息void Help(){system("cls");printf( "\n\n\n\n\t——————————-----—---——ATM系统帮助----------------------------------------\n""\t1、初始界⾯:客户插卡前或者退卡后ATM显⽰的界⾯,提⽰客户插卡操作及银⾏⼴告.\n""\t2、⾝份认证:需要客户插⼊银⾏卡后输⼊密码来验证所有权.\n""\t3、吞卡:客服若连续输⼊密码3次错误后,则将卡吞⼊ATM内.\n""\t4、账户:账户由银⾏卡的卡号、密码、银⾏系统⽤户信息组成.\n""\t5、业务操作:由查询余额、取款、存款、转账、取卡等事项组成.\n""\t6、查询余额:显⽰该账户中剩余⾦额.\n""\t7、取款:根据客户输⼊的⾦额从账户中扣除相应的⾦额,客户可以提取相应数额的现⾦.\n""\t8、存款:客户存⼊现⾦,账户根据现⾦数额增加剩余⾦额.\n""\t9、转账:客户输⼊另外⼀个账户号码和⾦额,从本账户的余额中减去该⾦额,增加到那个账号中.\n" "\t10、打印凭条:凭条由⽇期,银⾏卡的卡号,交易流⽔号组成.\n""\t11、取卡:客户取回银⾏卡.\n""\t————————————————-------------------------------------------------------\n");getch();return 1;}//查询账号void FindAccount(Node* pNode){Node* FNode = pNode;char AccountName[7];printf("请输⼊账号姓名:");scanf("%s", AccountName);while (FNode != NULL){if (strcmp(AccountName, FNode->) != 0){FNode = FNode->next;continue;}else{printf("该姓名的账户为:%s", FNode->P.account);return 1;}}printf("抱歉!该姓名未注册账号.");return 1;}int main(){system("color b0");while (1){system("cls");Menu();char ch = _getch();switch (ch){case '1':Register();break;case '2':Login();break;case '3':Help();break;case '4':FindAccount(HeadNode);getch();break;case '5':exit(0);default:break;}}return 0;}到此这篇关于C语⾔实现ATM系统程序的完整代码的⽂章就介绍到这了,更多相关c语⾔ATM系统程序内容请搜索以前的⽂章或继续浏览下⾯的相关⽂章希望⼤家以后多多⽀持!。

C语言实现ATM机存取款系统

C语言实现ATM机存取款系统

C语⾔实现ATM机存取款系统本⽂实例为⼤家分享了C语⾔实现ATM机存取款系统的具体代码,供⼤家参考,具体内容如下利⽤结构体和构造函数并且采⽤输⼊输出⽂件实现ATM机系统。

主要功能有:利⽤三种⽅法查询、开户、登陆、菜单、取款、修改密码、存款、转账、创建个⼈信息、输出、删除、增加、退出。

是⼀个功能齐全,完备的ATM机系统。

#include<stdio.h>#include<string.h>#include<stdlib.h>struct per //定义结构体{char name[20];char ID[20];int money;char mima[6];struct per * next;};typedef struct person //定义另⼀结构体{struct per kehu;struct person *next;}L;void chaxun(struct per *head); //各个函数的声明void kaihu(struct per *head);void denglu(struct per *head);void caidan(struct per *head);void qukuan(struct per *head);void xgmm(struct per *head);void cunkuan(struct per *head);void zhuanzhang(struct per *head);void chuangjian(struct person **Phead);void shuchu(struct person *Phead);void shanchu(struct person **Phead);void zengjia(struct person **Phead);void chaxun1(struct person *Phead);void chaxun2(struct person *Phead);void chaxun3(struct person *Phead);void tuichu();void menu();/*主函数*///void main(){char x;char choose; //choose为定义输⼊选择的变量int flag=1;struct person *Phead=NULL; //Phead为定义⼆层头指针struct per *head=NULL; //head为定义⼀层头指针printf("*****************************\n");printf("**欢迎使⽤ATM⾃动取款机系统**\n");printf("*****************************\n");printf("——————————————\n");printf("| 1 开户 |\n");printf("——————————————\n");printf("| 2 登陆 |\n");printf("——————————————\n");system("cls");switch(x){case '1':system("cls");kaihu(head); //调⽤开户函数break;case '2':system("cls");denglu(head); //调⽤登陆函数break;case '3':system("cls");menu(); //调⽤后台菜单函数break;}while(flag){system("cls");menu(); //调⽤后台菜单函数choose=getchar();switch(choose){case '1':chuangjian(&Phead);shuchu(Phead); //调⽤后台输出函数system("pause");system("cls");break;case '2':chaxun1(Phead); //调⽤后台卡号查询函数system("pause");system("cls");break;case '3':chaxun2(Phead); //调⽤后台姓名查询函数system("pause");system("cls");break;case '4':chaxun3(Phead); //调⽤后台余额查询函数system("pause");system("cls");break;case '5':shanchu(&Phead); //调⽤后台删除⽤户函数system("pause");system("cls");break;case '6':zengjia(&Phead); //调⽤后台增加⽤户函数system("pause");system("cls");break;case '7':shuchu(Phead); //调⽤后台输出函数函数system("pause");system("cls");break;case '8':shuchu(Phead);system("pause");system("cls");break;case '0':flag=0;printf("The end.\n");break;}}}/*开户函数*/void kaihu(struct per *head){head=NULL;FILE *fp; //定义⽂件指针struct per *p1=NULL,*p2=NULL; //p1,p2为定义链表指针 p1=(struct per*)malloc(sizeof(struct per)); //开辟内存单元scanf("%s",p1->mima);p1->money=0;p1->next=NULL;printf("您的个⼈信息为");printf("姓名:%s \n卡号:%s \n余额:%4d\n",p1->name,p1->ID,p1->money); if(NULL==head) //为新⽤户开辟内存单元{head=(struct per *)malloc(sizeof(struct per));head->next=p1; //进⾏头插法,将其作为第⼀个节点}else //为新增客户开辟内存单元{for(p2=head;p2->next!=NULL;p2=p2->next); //进⾏尾插p2->next=p1;}if((fp=fopen("save.txt","ab+"))==NULL) //打开⽂件{printf("cannot poen file\n");return;}if(fwrite(p1,sizeof(struct per),1,fp)!=1) //将链表信息写⼊⽂件中printf("file write error\n");fclose(fp);printf("\n");printf("恭喜您开户成功,请登录\n");system("pause");system("cls");denglu(head);}//登陆函数/void denglu(struct per *head){char d[20];char mima[20];int i,j;FILE *fp; //定义⽂件指针struct per *p,*q=NULL;if((fp=fopen("save.txt","rb+"))==NULL) //打开⼀个⼆进制⽂件,为读⽅式{printf("不能打开⽂件\n"); //如不能打开,则结束程序}p=(struct per*)malloc(sizeof(struct per)); //申请空间head=p;while(!feof(fp)) //循环读数据直到⽂件尾结束{if(1!=fread(p,sizeof(struct per),1,fp))break; //如果没读到数据,跳出循环p->next=(struct per *)malloc(sizeof(struct per)); //为下⼀个结点申请空间q=p; //保存当前节点的指针,作为下⼀结点的前驱p=p->next; //指针后移,新读⼊数据链到当前表尾}q->next=NULL; //最后⼀个结点的后继指针为空fclose(fp);printf(" **********************\n");printf(" ***欢迎来都建设银⾏***\n");printf(" **********************\n");for(j=1;j<4;j++) //限制卡号输⼊的次数的循环{printf("请输⼊您的卡号\n");scanf("%s",d);for(q=head;q!=NULL;q=q->next) //遍历链表{if(strcmp(q->ID,d)!=0) //核对账号{continue; //跳出循环}scanf("%s",mima);if(strcmp(q->mima,mima)!=0) //核对密码{printf("密码不正确。

ATMC语言编程源代码

ATMC语言编程源代码

#include<stdio.h>/*引用库函数*/#include<stdlib.h>#include<string.h>#include<conio.h>#include<time.h>#define ZHANGHUSHU 10#define JIAOYISHU 20int caidan();/*登录注册菜单*/void zhuce();void denglu();void baocunshuju();int menu();/*主菜单*/void cunkuan();void qukuan();void zhuanzhang();void chaxun();void xiugaimima();struct JiaoYi /*定义交易结构体*/{char shijian[50];/*时间*/char leixing[3];/*类型*/float jine; /*金额*/float yue;/*余额*/};struct ZhangHu /*定义账户结构体*/{char xingming[17];/*姓名*/char zhanghao[12];/*账号*/char shenfenzheng[19]; /*身份证*/char mima[7]; /*密码*/float yue; /*余额*/struct JiaoYi jiaoyi[JIAOYISHU]; /*在账户的结构体中在定义交易的结构体*/int jiaoyishu;};struct ZhangHu zhanghu[ZHANGHUSHU]; /*定义账户数来确定账户这一结构体中有多少个体*/int j; /*当前账户*/int zhanghushu;int k;/*交易帐号*/int jiaoyishu;void xianshizhanghu();int caidan()/*菜单函数*/{char c;do{system("cls"); /*每次选择运行前清屏*/printf("\t\t =================欢迎使用ATM系统===============\n\n"); /*菜单选择*/printf("\t\t * 1. 注册* *\n");printf("\t\t * 2. 登录*\n");printf("\t\t * 3. 保存数据*\n");printf("\t\t * 0. 退出*\n");printf("\t\t===============================================\n");printf("\t\t\t请作出选择(0-3):");c=getchar(); /*读入选择*/}while(c<'0'||c>'3');return(c-'0'); /*c变为空后返回重新选择*/}/*根据主菜单的返回值来确定主函数的值*/void zhuce(){printf("\n\t\t请输入姓名:");scanf("%s",zhanghu[zhanghushu].xingming);printf("\n\t\t请输入帐号:");scanf("%s",zhanghu[zhanghushu].zhanghao);do{printf("\n\t\t请输入身份证:");scanf("%s",zhanghu[zhanghushu].shenfenzheng);if(strlen(zhanghu[zhanghushu].shenfenzheng)==18)break;elseprintf("\n\t\t身份证必须是18,请重新输入!");}while(1);do{ printf("\n\t\t请输入密码:");scanf("%s",zhanghu[zhanghushu].mima);if(strlen(zhanghu[zhanghushu].mima)==6)break;elseprintf("\n\t\t密码必须是6位,请重新输入!");}while(1);zhanghu[zhanghushu].yue=0;zhanghu[zhanghushu].jiaoyishu=0;zhanghushu++;xianshizhanghu();}void xianshizhanghu() /*显示账户函数来显示所输入的账户*/{int i;for(i=0;i<zhanghushu;i++){printf("\n\n\t帐号\t姓名\t身份证\t\t密码\t余额\n");printf("\t%s\t%s\t%s\t%s\t%.2f\n",zhanghu[i].zhanghao,zhanghu[i].xing ming,zhanghu[i].shenfenzheng,zhanghu[i].mima,zhanghu[i].yue);system("pause");}}void denglu() /*登录函数*/{char zhanghao[12],mima[7];int i=0;int mimacishu=1;printf("\n\t\t请输入帐号:");scanf("%s",zhanghao);while(strcmp(zhanghao,zhanghu[i].zhanghao)!=0&&i<zhanghushu)i++; /**/if(i==zhanghushu)return;do{printf("\n\t\t请输入密码:");scanf("%s",mima);if(strcmp(mima,zhanghu[i].mima)!=0){if(mimacishu==3){printf("你已输入错误三次,你不能在输."); system("pause");return;}else{printf("密码错误请重新输入:");mimacishu++;}}elsebreak;}while(1);for(;;){switch(menu()) /*选择判断*/{case 1:cunkuan();break;case 2:qukuan();break;case 3:zhuanzhang();break;case 4:chaxun();break;case 5:xiugaimima();break;case 0:return;}}}void baocunshuju()/*保存数据*/{int i,j;FILE *fp;char filename[20];printf("\t\t\t将数据保存到一个文本文件中\n");/*输入文件名*/printf("\t\t\t请输入文件名");fflush(stdin);scanf("%s",filename);if((fp=fopen(filename,"w"))==NULL)/*打开文件*/{printf("无法创建此文件\n");system("pause");return;}fprintf(fp,"%d\n",zhanghushu);/*循环写入数据*/printf("\t帐号\t\t姓名\t\t身份证\t\t密码\t余额\t交易数");for(i=0;i<zhanghushu;i++){fprintf(fp,"\t%15s%10s%20s%10s\t%10.2f\t%5d\n",zhanghu[i].zhanghao,zh anghu[i].xingming,zhanghu[i].shenfenzheng,zhanghu[i].mima,zhanghu[i]. yue,zhanghu[i].jiaoyishu);for(j=0;j<zhanghu[i].jiaoyishu;j++)fprintf(fp,"%30s%10s%10.2f%10.2f\n",zhanghu[i].jiaoyi[j].shijian,zhan ghu[i].jiaoyi[j].leixing,zhanghu[i].jiaoyi[j].jine,zhanghu[i].jiaoyi[ j].yue);}fclose(fp);}void duqushuju(){int i,j;FILE *fp;char filename[20];printf("\n\n\n\t请输入欲读入数据的文件名:\n");fflush(stdin);gets(filename);if(strlen(filename)==0)return;elseif((fp=fopen(filename,"r"))==NULL)/*打开文件*/{printf("无法打开此文件\n");system("pause");return;}else{printf("\t\t成功打开文件.\n");getch();}fscanf(fp,"%d\n",zhanghushu);for(i=0;i<zhanghushu;i++){fscanf(fp,"%15s%10s%20s%10f\t%10f%5d\n",zhanghu[i].zhanghao,zhanghu[i].xingming,zhanghu[i].shenfenzheng,zhanghu[i].mima,&zhanghu[i].yue,&zhanghu[i].jiaoyishu);for(j=0;j<zhanghu[i].jiaoyishu;j++){fgets(zhanghu[i].jiaoyi[j].shijian,30,fp);fscanf(fp,"%5s%10f\t%10f\n",zhanghu[i].jiaoyi[j].leixing, &(zhanghu[i].jiaoyi[j].jine),&(zhanghu[i].jiaoyi[j].yue));}}fclose(fp);}int menu(){char c;do{system("cls");printf("\n\n\t================= 欢迎使用 XXX银行ATM==================\n\n");printf("\t=====================请选择服务=====================\n");printf("\t**\n");printf("\t* 1 实时存款 2 取款服务*\n");printf("\t**\n");printf("\t* 3 转账服务 4 查询*\n");printf("\t**\n");printf("\t* 5 修改密码 6 退出*\n");printf("\t**\n");printf("\t====================================================\n" );printf("\t\t\t请作出选择(1-7):");c=getchar(); /*读入选择*/system("pause");}while(c<'1'||c>'7');return(c-'0'); /*c变为空后返回重新选择*/}void cunkuan() /*存款函数*/{float cunkuanjine;/*输入的存款金额*/int k;int i;char t[30];time_t rawtime;struct tm *timeinfo;time(&rawtime);timeinfo=localtime(&rawtime);strcpy(t,asctime(timeinfo));for(i=0;t[i]!='\0';i++)if(t[i]=='\n'){t[i]='\0';break;}printf("请输入存款金额(存款金额必须大于0,不超过10000,必须是100元的面额\n");scanf("%f",&cunkuanjine);if(cunkuanjine<=0||cunkuanjine>1000||(int)cunkuanjine%100!=0) {printf("金额不符合要求,请重新选择");return;}else{k=zhanghu[j].jiaoyishu;strcpy(zhanghu[j].jiaoyi[k].shijian,t);strcpy(zhanghu[j].jiaoyi[k].leixing,"存");zhanghu[j].jiaoyi[k].jine=cunkuanjine;zhanghu[j].yue+=cunkuanjine;zhanghu[j].jiaoyi[k].yue=zhanghu[j].yue;zhanghu[j].jiaoyishu++;printf("\n\\t\t\t您本次存了%.2f元\n",cunkuanjine);printf("\n\\t\t\t您的余额为%.2f元\n",zhanghu[j].yue);printf("\n时间为:%s\n",zhanghu[j].jiaoyi[k].shijian);printf("\n类型为:%s\n",zhanghu[j].jiaoyi[k].leixing);system("pause");}}void qukuan() /*取款函数*/{int k;/*交易下标*/float qukuanjine;int i;char t[30];time_t rawtime;struct tm *timeinfo;time(&rawtime);timeinfo=localtime(&rawtime);strcpy(t,asctime(timeinfo));for(i=0;t[i]!='\0';i++)if(t[i]=='\n'){t[i]='\0';break;}printf(" 取款服务 \n");printf("\t=====================请选择服务=====================\n");printf("\t**\n");printf("\t* 1 100 2 200*\n");printf("\t**\n");printf("\t* 3 500 4 1000*\n");printf("\t**\n");printf("\t* 5 其他金额 6 返回主菜单*\n");printf("\t**\n");printf("\t====================================================\n" );scanf("%f",&qukuanjine);if(qukuanjine<=0||qukuanjine>10000||(int)qukuanjine%100!=0){printf("金额不符合要求,请重新选择");return;}elseif(zhanghu[j].yue<qukuanjine){printf("你的账户余额不足,不能完成这项操作。

ATM取款机代码

ATM取款机代码
printf("您的余额不足\n按任意键返回\n");
getch();
}
else
{
person[i].money-=800;
printf(">>>>>>>>>>>>>>>>>\n");
printf("您已取款800元\n按任意键返回\n");
getch();
}
goto no2;
case 4: if(1000> person[i].money)
else
printf(">>>>>>>>>>>>>>>>>\n您输入的帐户有误请重新输入:\n");
}
printf(">>>>>>>>>>>>>>>>>\n");
printf("请选择转帐金额:\n");
scanf("%d",&key2);
switch(key2)
{
case 1:if(100> person[i].money)
getch();
}
goto no2;
case 2:if(400> person[i].money)
{
printf(">>>>>>>>>>>>>>>>>\n");

ATMC语言编程源代码.doc

ATMC语言编程源代码.doc

#include<stdio.h>/*引用库函数*/#include<stdlib.h>#include<string.h>#include<conio.h>#include<time.h>#define ZHANGHUSHU 10#define JIAOYISHU 20int caidan();/*登录注册菜单*/void zhuce();void denglu();void baocunshuju();int menu();/*主菜单*/void cunkuan();void qukuan();void zhuanzhang();void chaxun();void xiugaimima();struct JiaoYi /*定义交易结构体*/{char shijian[50];/*时间*/char leixing[3];/*类型*/float jine; /*金额*/float yue;/*余额*/};struct ZhangHu /*定义账户结构体*/{char xingming[17];/*姓名*/char zhanghao[12];/*账号*/char shenfenzheng[19]; /*身份证*/char mima[7]; /*密码*/float yue; /*余额*/struct JiaoYi jiaoyi[JIAOYISHU]; /*在账户的结构体中在定义交易的结构体*/int jiaoyishu;};struct ZhangHu zhanghu[ZHANGHUSHU]; /*定义账户数来确定账户这一结构体中有多少个体*/int j; /*当前账户*/int zhanghushu;int k;/*交易帐号*/int jiaoyishu;void xianshizhanghu();int caidan()/*菜单函数*/{char c;do{system("cls"); /*每次选择运行前清屏*/printf("\t\t =================欢迎使用ATM系统===============\n\n"); /*菜单选择*/printf("\t\t * 1. 注册* *\n");printf("\t\t * 2. 登录*\n");printf("\t\t * 3. 保存数据*\n");printf("\t\t * 0. 退出*\n");printf("\t\t===============================================\n");printf("\t\t\t请作出选择(0-3):");c=getchar(); /*读入选择*/}while(c<'0'||c>'3');return(c-'0'); /*c变为空后返回重新选择*/}/*根据主菜单的返回值来确定主函数的值*/void zhuce(){printf("\n\t\t请输入姓名:");scanf("%s",zhanghu[zhanghushu].xingming);printf("\n\t\t请输入帐号:");scanf("%s",zhanghu[zhanghushu].zhanghao);do{printf("\n\t\t请输入身份证:");scanf("%s",zhanghu[zhanghushu].shenfenzheng);if(strlen(zhanghu[zhanghushu].shenfenzheng)==18)break;elseprintf("\n\t\t身份证必须是18,请重新输入!");}while(1);do{ printf("\n\t\t请输入密码:");scanf("%s",zhanghu[zhanghushu].mima);if(strlen(zhanghu[zhanghushu].mima)==6)break;elseprintf("\n\t\t密码必须是6位,请重新输入!");}while(1);zhanghu[zhanghushu].yue=0;zhanghu[zhanghushu].jiaoyishu=0;zhanghushu++;xianshizhanghu();}void xianshizhanghu() /*显示账户函数来显示所输入的账户*/{int i;for(i=0;i<zhanghushu;i++){printf("\n\n\t帐号\t姓名\t身份证\t\t密码\t余额\n");printf("\t%s\t%s\t%s\t%s\t%.2f\n",zhanghu[i].zhanghao,zhanghu[i].xing ming,zhanghu[i].shenfenzheng,zhanghu[i].mima,zhanghu[i].yue);system("pause");}}void denglu() /*登录函数*/{char zhanghao[12],mima[7];int i=0;int mimacishu=1;printf("\n\t\t请输入帐号:");scanf("%s",zhanghao);while(strcmp(zhanghao,zhanghu[i].zhanghao)!=0&&i<zhanghushu)i++; /**/if(i==zhanghushu)return;do{printf("\n\t\t请输入密码:");scanf("%s",mima);if(strcmp(mima,zhanghu[i].mima)!=0){if(mimacishu==3){printf("你已输入错误三次,你不能在输."); system("pause");return;}else{printf("密码错误请重新输入:");mimacishu++;}}elsebreak;}while(1);for(;;){switch(menu()) /*选择判断*/{case 1:cunkuan();break;case 2:qukuan();break;case 3:zhuanzhang();break;case 4:chaxun();break;case 5:xiugaimima();break;case 0:return;}}}void baocunshuju()/*保存数据*/{int i,j;FILE *fp;char filename[20];printf("\t\t\t将数据保存到一个文本文件中\n");/*输入文件名*/printf("\t\t\t请输入文件名");fflush(stdin);scanf("%s",filename);if((fp=fopen(filename,"w"))==NULL)/*打开文件*/{printf("无法创建此文件\n");system("pause");return;}fprintf(fp,"%d\n",zhanghushu);/*循环写入数据*/printf("\t帐号\t\t姓名\t\t身份证\t\t密码\t余额\t交易数");for(i=0;i<zhanghushu;i++){fprintf(fp,"\t%15s%10s%20s%10s\t%10.2f\t%5d\n",zhanghu[i].zhanghao,zh anghu[i].xingming,zhanghu[i].shenfenzheng,zhanghu[i].mima,zhanghu[i]. yue,zhanghu[i].jiaoyishu);for(j=0;j<zhanghu[i].jiaoyishu;j++)fprintf(fp,"%30s%10s%10.2f%10.2f\n",zhanghu[i].jiaoyi[j].shijian,zhan ghu[i].jiaoyi[j].leixing,zhanghu[i].jiaoyi[j].jine,zhanghu[i].jiaoyi[ j].yue);}fclose(fp);}void duqushuju(){int i,j;FILE *fp;char filename[20];printf("\n\n\n\t请输入欲读入数据的文件名:\n");fflush(stdin);gets(filename);if(strlen(filename)==0)return;elseif((fp=fopen(filename,"r"))==NULL)/*打开文件*/{printf("无法打开此文件\n");system("pause");return;}else{printf("\t\t成功打开文件.\n");getch();}fscanf(fp,"%d\n",zhanghushu);for(i=0;i<zhanghushu;i++){fscanf(fp,"%15s%10s%20s%10f\t%10f%5d\n",zhanghu[i].zhanghao,zhanghu[i].xingming,zhanghu[i].shenfenzheng,zhanghu[i].mima,&zhanghu[i].yue,&zhanghu[i].jiaoyishu);for(j=0;j<zhanghu[i].jiaoyishu;j++){fgets(zhanghu[i].jiaoyi[j].shijian,30,fp);fscanf(fp,"%5s%10f\t%10f\n",zhanghu[i].jiaoyi[j].leixing, &(zhanghu[i].jiaoyi[j].jine),&(zhanghu[i].jiaoyi[j].yue));}}fclose(fp);}int menu(){char c;。

C语言模拟ATM提款机

C语言模拟ATM提款机

C语言模拟ATM提款机1.运用结构体2.运用文件调用源代码:#include "stdio.h"#include "stdlib.h"#include "conio.h"#define N 200void zhanghao(); //账号void xuanzhe(); //选择函数void enter_ATM(); //账号输入函数void input_code(); //密码输入函数void caozuo(); //基本操作界面void qukuan(); //取款函数void success(); //操作成功函数void delay(); //延时函数void YU_E(); //余额查询函数void cunkuan(); //存款函数void panduan(double z); //判断取款是否合法函数void exit(); //退出界面函数void mima(); //密码修改void zhuanzhang(); //转账函数void read(); //文件写入函数void write(); //文件读取函数void guanli(); //管理员函数void tequancode(); //管理员密码void hu(); //户void xinxi(); //信息void gmima(); //管理员改密void CAOZUO(); //管理员操作函数void yinghang(); //银行账户查询函数void jia(); //账户添加函数void shanchu(); //账户删除函数typedef struct{long int zhanghao;int mima;double yu_e;}atm;atm guan[N];int k;////////////////////////////////////////////////////////////主函数void main(){xuanzhe();}////////////////////////////////////////////////////////////功能选择函数void xuanzhe(){system("cls");printf("* 请选择功能*\n");printf("* 1.管理员 2.用户*\n");switch(getch()){case '1':tequancode();break;case '2':enter_ATM();break;default:{printf("\a非法输入");delay();system("cls");xuanzhe();};break;}}///////////////////////////////////////////////////////////柜台机账号输入函数void enter_ATM(){delay();system("cls");read();printf("* 欢迎使用ATM 柜台机*\n");printf("* 请输入卡号*\n");long int user;scanf("%d",&user);if(user==0){printf("* 账号错误*\n");enter_ATM();}else if(user!=(guan[k].zhanghao)){for(k=1;k<N;k++){if(user==(guan[k].zhanghao))input_code( );}system("cls");printf("* 账户不存在,请从新输入*\n");enter_ATM();}elseinput_code( );}////////////////////////////////////////////////////////////////密码输入函数void input_code( ){long int code;int temp=3;read();system("cls");printf("* 请输入密码*\n");scanf("%d",&code);while(code!=guan[k].mima){temp--;system("cls");printf("* 密码错误,请重新输入*\n");printf("* 您还有");printf("%d",temp);printf(" 次机会*\n");scanf("%d",&code);if(temp==1){system("cls");printf("* 您已经3 次输入密码*\n");printf("* 系统将退出操作*\n");delay();enter_ATM();}}caozuo();}//////////////////////////////////////////////////////////////////主操作界面函数void caozuo( ){system("cls");printf("********************************\n");printf("* 1.修改密码*\n");printf("* 2.查询余额*\n");printf("* 3.取款*\n");printf("* 4.存款*\n");printf("* 5.转账*\n");printf("* 6.退出*\n");printf("********************************\n");switch(getch( )){case '1': mima(); break;case '2': YU_E(); break;case '3': qukuan(); break;case '4': cunkuan(); break;case '5': zhuanzhang();break;case '6': exit(); break;default:{printf("\a非法操作\n");caozuo();};}}//////////////////////////////////////////////////////////////////////密码修改函数void mima(){long int mm1,mm2,mm3;int temp;system("cls");printf("旧密码:");scanf("%d",&mm1);printf("\n");if(mm1!=guan[k].mima){system("cls");printf("旧密码错误,请重新输入\n");delay();mima();}printf("新密码:");scanf("%d",&mm2);if(mm2<100000||mm2>999999){system("cls");printf(" 密码必须等于6位数\n");delay();mima();}temp=mm2%111111;if(temp==0){system("cls");printf(" 密码过于简单\n");printf(" 请重新输入!\n");delay( );mima( );}printf("\n");printf("确认新密码:");scanf("%d",&mm3);if(mm2!=mm3){system("cls");printf("确认密码不一致,请重新输入\n");delay( );mima();}if(mm3=mm2){guan[k].mima=mm3;write();success();}}////////////////////////////////////////////////////////////////////余额查询函数void YU_E(){read();system("cls");printf("你的余额为:%lf\n",(guan[k].yu_e));printf("1.返回 2.退出\n");switch(getch()){case '1': caozuo(); break;case '2': exit(); break;}}/////////////////////////////////////////////////////////////////////////取款函数void qukuan(){double temp;system("cls");printf(" 请选择您要取款的金额\n");printf(" 1.100 2.200 \n");printf(" 3.500 4.800 \n");printf(" 5.1000 6.其它\n");printf(" \n");printf(" 7.返回8.退出\n");switch(getch()){case '1': panduan(100); break;case '2': panduan(200); break;case '3': panduan(500); break;case '4': panduan(800); break;case '5': panduan(1000); break;case '6':system("cls");printf("请输入您要取款的金额:");scanf("%lf",&temp);panduan(temp); break;case '7':caozuo(); break;case '8':exit(); break;}}///////////////////////////////////////////////////////////////////判断取款是否合法函数void panduan(double z){int beishu;if(z>(guan[k].yu_e)){system("cls");printf(" 余额不足!\n");printf(" 请重新操作\n");printf(" 1.返回 2.退出\n");switch(getch()){case '1': qukuan();case '2': exit();}}beishu=(int)z%100;if(beishu!=0){system("cls");delay( );printf(" 本ATM机只支持100 的人民币\n");printf(" 请重新操作\n");printf(" \n");printf(" 1.返回 2.退出\n");switch(getch()){case '1': qukuan();case '2': exit();}}if(z==5000.00||z>5000.00){system("cls");printf(" 每次取款不能超过5000 元\n");printf(" 请重新操作\n");printf(" \n");printf(" 1.返回 2.退出\n");switch(getch()){case '1': qukuan();case '2': exit();}}(guan[k].yu_e)-=z;write();success();}/////////////////////////////////////////////////////////////////存款函数void cunkuan( ){double cun;system("cls");printf(" 请放入人民币:");scanf("%lf",&cun);while(cun<0){system("cls");printf(" 非法存款\n");printf(" 请重新放入人民币\n");scanf("%lf",&cun);}(guan[k].yu_e)+=cun;write();success();}/////////////////////////////////////////////////////////////////转账号函数void zhuanzhang(){int i,hao;double money;long int a=2109999999;system("cls");delay();read();printf("* 请输入账号*\n");scanf("%d",&hao);printf("* 请输入金额*\n");scanf("%lf",&money);if(hao<1000000000||hao>a){printf("* 账号错误,操作取消*\n");delay();delay();caozuo();}else if(money>guan[k].yu_e||money<0){printf("* 金额错误,操作取消*\n");delay();delay();caozuo();}else{read();for(i=1;i<N;i++){if(guan[i].zhanghao==hao)break;}guan[k].yu_e-=money;guan[i].yu_e+=money;write();success();}}///////////////////////////////////////////////////////延时函数void delay( ){long int bl1;int bl2;for(bl1=600000;bl1>0;bl1--){for(bl2=300;bl2>0;bl2--);}}/////////////////////////////////////////////////操作成功函数void success( ){system("cls");printf(" 操作已成功\n");printf(" \n");printf(" 1.返回 2.退出\n");switch(getch()){case '1':caozuo(); break;case '2':exit(); break;}}//////////////////////////////////////////////系统退出函数void exit(){system("cls");printf("* 欢迎您的再次使用*\n");printf("* 系统正在退出... *\n");delay();xuanzhe();}////////////////////////////////////////////////////文件读取函数void read(){int i;FILE *fp;fp=fopen("xinxi.txt","r");if(fp==NULL){printf("打开文件失败\n");return;}for(i=0;i<N;i++){fscanf(fp,"%d ",&(guan[i].zhanghao));fscanf(fp,"%d ",&(guan[i].mima));fscanf(fp,"%lf\n",&(guan[i].yu_e));}fclose(fp);}/////////////////////////////////////////////////////////////文件写入函数void write(){int i;FILE *fp;fp=fopen("xinxi.txt","w");if(fp==NULL){printf("打开文件失败\n");return;}for(i=0;i<N;i++){fprintf(fp,"%d ",guan[i].zhanghao);fprintf(fp,"%d ",guan[i].mima);fprintf(fp,"%lf\n",guan[i].yu_e);}fclose(fp);}void tequancode( ){long int code;int temp=2;read();system("cls");printf("* 请输入管理员密码*\n");scanf("%d",&code);while(code!=guan[0].mima){system("cls");printf("* 密码错误,请重新输入*\n");printf("* 您还有");printf("%d",temp);printf(" 次机会*\n");scanf("%d",&code);temp--;if(temp==0){system("cls");printf("*\a 您已经3 次输入密码*\n");printf("* 系统将退出操作*\n");delay();xuanzhe();}}guanli();}////////////////////////////////////////////////////////////////管理员函数void guanli(){system("cls");delay();printf("* 1.信息查询*\n");printf("* 2.操作*\n");printf("* 3.退出*\n");switch(getch()){case '1':zhanghao();break;case '2':CAOZUO();break;case '3':exit();break;default:{printf("\a非法操作");guanli();};}}/////////////////////////////////////账号void zhanghao(){system("cls");read();printf(" 请输入账号\n");long int user;scanf("%d",&user);if(user!=(guan[k].zhanghao)){for(k=1;k<N;k++){if(user==(guan[k].zhanghao))hu();}system("cls");printf("* 账户不存在,请从新输入*\n");delay();guanli();}else{delay();hu( );}}////////////////////////////////////////////////账户void hu(){system("cls");printf("* 1.信息 2.改密码*\n");printf("* 3.返回 4.退出*\n");switch(getch()){case '1':xinxi();break;case '2':gmima();break;case '3':zhanghao();break;case '4':guanli();break;default:{printf("\a非法操作\n");hu();};}}///////////////////////////////////////////////信息void xinxi(){system("cls");read();printf("*账号密码余额*\n");printf("%d ",guan[k].zhanghao);printf("%d ",guan[k].mima);printf("%lf \n",guan[k].yu_e);printf("* 1.返回 2.退出*\n");switch(getch()){case '1':hu();break;case '2':guanli();break;}}///////////////////////////////////////////管理员改密void gmima(){long int mm1,mm2,mm3;char temp;system("cls");printf("旧密码:");scanf("%d",&mm1);printf("\n");if(mm1!=guan[k].mima){system("cls");printf("旧密码错误,请重新输入\n");delay();gmima();}printf("新密码:");scanf("%d",&mm2);if(mm2<100000||mm2>999999){system("cls");printf(" 密码必须等于6位数\n");printf(" 请重新输入!\n");delay();gmima();}temp=mm2%111111;if(temp==0){system("cls");printf(" 密码过于简单\n");printf(" 请重新输入!\n");delay( );gmima( );}printf("\n");printf("确认新密码:");scanf("%d",&mm3);if(mm2!=mm3){system("cls");printf("确认密码不一致,请重新输入\n");delay( );gmima();}if(mm3=mm2){guan[k].mima=mm3;write();hu();}}///////////////////////////////////////////管理员操作函数void CAOZUO(){system("cls");delay();printf("* 1.查询所有账户*\n");printf("* 2.添加账户*\n");printf("* 3.删除账户*\n");printf("* 4.返回 5.退出*\n");switch(getch()){case '1':yinghang();break;case '2':jia();break;case '3':shanchu();break;case '4':guanli();break;case '5':xuanzhe();break;default:{printf("\a非法操作\n");CAOZUO();};}}//////////////////////////////////////////银行账户查询函数void yinghang(){system("cls");delay();read();printf("*账号密码余额*\n");for(;k<N;k++){if(guan[k].zhanghao!=0&&guan[k].zhanghao>0){printf("%d ",guan[k].zhanghao);printf("%d ",guan[k].mima);printf("%lf\n",guan[k].yu_e);}}printf("* 1.返回 2.退出*\n");switch(getch()){case '1':CAOZUO();break;case '2':guanli();break;}}//////////////////////////////////////////账户添加函数void jia(){int mm1,mm2;int temp;system("cls");delay();read();printf("* 请输入密码*\n");scanf("%d",&mm1);if(mm1<100000||mm1>999999){system("cls");printf(" 密码必须等于6位数\n");printf(" 请重新输入: \n");delay();scanf("%d",&mm1);}temp=mm1%111111;if(temp==0){system("cls");printf(" 密码过于简单\n");printf(" 请重新输入: \n");delay( );scanf("%d",&mm1);}printf("\n");printf("确认密码:\n");scanf("%d",&mm2);if(mm1!=mm2){system("cls");printf("确认密码不一致,操作取消\n");delay( );CAOZUO();}if(mm1=mm2){for(;k<N;k++){if(guan[k].zhanghao==0){guan[k].zhanghao=guan[k-1].zhanghao+1;guan[k].mima=mm2;write();break;}}printf("账号创建成功!\n");printf("您的账号是%d,请妥善保管!\n",guan[k].zhanghao);printf("* 1.返回 2.退出*\n");switch(getch()){case '1':CAOZUO();break;case '2':guanli();break;}}}/////////////////////////////////////////账户删除函数void shanchu(){system("cls");delay();read();printf("* 请输入账号*\n");long int user;scanf("%d",&user);if(user==0){printf("* 账号错误,操作取消*\n");CAOZUO();}else if(user!=(guan[k].zhanghao)){for(k=1;k<N;k++){if(user==(guan[k].zhanghao)){for(;k<N;k++){guan[k].zhanghao=guan[k+1].zhanghao;guan[k].mima=guan[k+1].mima;guan[k].yu_e=guan[k+1].yu_e;write();}printf("账号删除成功!\n");printf("* 1.返回 2.退出*\n");switch(getch()){case '1':CAOZUO();break;case '2':guanli();break;}}}system("cls");printf("* 账户不存在*\n");delay();CAOZUO();}else{for(;k<N;k++){guan[k].zhanghao=guan[k+1].zhanghao;guan[k].mima=guan[k+1].mima;guan[k].yu_e=guan[k+1].yu_e;write();}printf("账号删除成功!\n");printf("* 1.返回 2.退出*\n");switch(getch()){case '1':CAOZUO();break;case '2':guanli();break;}}}。

c语言模拟ATM机程序

c语言模拟ATM机程序
case 3: Zhuanzhang(&Y,&a[6]);break;
case 4: Xiugai(&a[6]);break;
case 5: Cunkuan(&Y);break;
case 6: exit(0);break;
default:printf("输入错误,请重新输入\n");
}
lp2:printf("继续操作请按1,退卡请按2\n");
else
{printf("非法操作,强制退出\n");
}
}
void Qukuan()
{
int i,j;
printf("1、100\t2、200\t3、500\t4、800\t5、请输入金额\n");
scanf("%d",&i);
switch(i)
{
case 1: panduan(100);break;
printf请选择服务项目n1取款t2查询服务t3转账服务t4修改密码t5存款t6退卡n
#include<stdlib.h>
#include<stdio.h>
#include<conio.h>
long int Y=100000;int c=0;char a[6]={'1','2','3','4','5','6'};
else
lp4:{
printf("请输入新密码:\n");
k=getch();
while(k!='\r'&&l<6)
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

//ATM自动取款机C语言源代码
#include<stdio.h>
#include<stdlib.h>
void main()
{
int choice(int n,int money);
int balance=1000000;
int password,m=0;
int n=0;
printf("\n\n\n\n\n\n\n\n");
printf(" 欢迎使用ATM自动取款机!\n");
printf(" welcome to this system \n\n");
printf(" 按回车键继续\n");
printf(" press Enter to continue\n");
getchar();
system("cls");
do
{
if (n==0)
{
printf("\n\n\n\n\n\n\n\n\n");
printf(" 请输入您的密码\n");
printf(" please input your password\n");
}
else
{
printf(" 您输入的密码有误,请重新输入:\n");
printf(" The password is wrong,please input again:\n");
}
scanf("%d",&password);
n++;
}
while (password!=123456&&n!=3);
system("cls");
if (password==123456)
do
{
printf("\n\n\n\n\n\n\n\n");
printf(" 欢迎使用A TM自动取款机!\n");
printf(" welcome to this system of ATM! \n");
printf(" ********************************\n");
printf(" 1.取款Debit Withdrawal \n");
printf(" 2.存款Credit Deposit\n");
printf(" 3.余额查询Seek\n");
printf(" 4.退出Exit\n");
printf(" ********************************\n");
choice(m,balance);
printf(" 继续请输入Y\n");
printf(" If you want to continue ,Press Y\n");
getchar();
}
while(getchar()=='Y');
else
{
printf("\n\n\n\n\n\n\n\n");
printf(" 您好,由于您三次输入密码有误,我们将没收您的卡,请您在一周内持有效证件于银行办理取卡手续.\n");
printf( " your password is wrong, we will sequestrate you card,please take you effective papers come to bank get your card back\n ");
}
}
int choice(int n,int money)
{
int m=0;
static int flag=1000000;
printf(" 请输入你的选择\n");
printf(" please choice: \n ");
scanf("%d",&n);
system("cls");
if(n==1)
{
printf("\n\n\n\n\n\n\n\n");
printf(" 请输入取款金额:\n");
printf(" please input what you want to debit:");
scanf("%d",&m);
flag=flag-m;
printf("\n");
printf(" 请稍后...\n");
printf(" please wait...\n\n");
printf(" 您的余额为balance:%d \n\n\n ",flag);
printf(" 交易成功!\n");
printf(" the transaction succeed!\n");
}
else if(n==2)
{
printf(" 请输入您要存入的金额:\n");
printf(" please input what you want to credit:");
scanf("%d",&m);
flag=flag+m;
printf("\n");
printf(" 请稍后...\n");
printf(" please wait...\n\n\n");
printf(" 您的余额为balance:%d \n\n\n",flag);
printf(" 交易成功!\n");
printf(" the transaction succeed!\n\n");
}
else if(n==3)
{
printf(" 请稍后...\n");
printf(" please wait...\n\n");
printf(" 您的余额为balance:%d元\n\n",flag);
}
else if(n==4)
{
printf(" 请取卡,谢谢使用!\n");
printf(" please take you card!\n");
}
else
{
printf(" 输入错误!\n");
printf(" Error!\n");
}
return flag;
}。

相关文档
最新文档