use C Make a simple ATM system , All codes have comments , Easy to understand .
Not much , The code is as follows :
#include<stdio.h> #include<stdlib.h> #include<string.h> #include<conio.h>
// Define function struct users { char name[20];// user name char pass[7];// password int account;// account number
float money;// balance }user[100]; int count=0; int account=2017062000; int find; int
dFind; int isLogout=0; // Loading interface void loading(){ int t=1;// Number of decimal points for(int
i=1;i<=100;i++) { printf("\n\n\t\t\t\t\t\t Welcome to ATM Bank management system ");
printf("\n\n\t\t\t\t\t\t One moment please "); for(int j=1;j<=t;j++){ printf("."); } t++;
if(t==10)t=1; printf("\n\n\t\t\t\t\t\t%d%%",i); for(int
k=0;k<=5000000;k++);// delay system("cls");// Clear screen } } // Check the balance void selectMoney(){
system("cls");// Clear screen printf("\n\n\n\n\t\t\t\t You are using the balance query function ");
printf("\n\n\t\t\t\t Your account balance is :%lf",user[find].money); } // Cash deposit void saveMoney(){
system("cls");// Clear screen printf("\n\n\n\n\t\t\t\t You are using the deposit function "); int RMB;
printf("\n\n\t\t\t\t Please enter the deposit amount :"); scanf("%d",&RMB);
user[find].money=user[find].money+RMB; printf("\n\n\t\t\t\t Deposit successful "); } // Withdrawal of deposit
void getMoney(){ system("cls");// Clear screen printf("\n\n\n\n\t\t You are using the withdrawal function "); int RMB;
printf("\n\n\t\t Please enter withdrawal amount :"); scanf("%d",&RMB); if(user[find].money>=RMB){
user[find].money=user[find].money-RMB; printf("\n\n\t\t Withdrawal succeeded "); }else{
printf("\n\n\t\t Sorry, your credit is running low "); } } // Amount transfer void transferMoney(){ system("cls");// Clear screen int
username;// account number int isFind=0; int RMB;// Transfer amount printf("\n\n\n\n\t\t You are using the transfer function ");
printf("\n\n\t\t Please enter the other party's account number :"); scanf("%d",&username); for(int i=0;i<count;i++){
if(username==user[i].account){ dFind=i; isFind=1; break; } } if(isFind==1){
printf("\n\n\t\t Please enter the transfer amount :"); scanf("%d,",&RMB); if(user[find].money>=RMB){
user[find].money=user[find].money-RMB; user[dFind].money=user[dFind].money+RMB;
printf("\n\n\t\t Transfer succeeded "); }else{ printf("\n\n\t\t Sorry, your credit is running low "); } }else{
printf("\n\n\t\t Target account does not exist "); } } // cancellation void logout(){ system("cls");// Clear screen char
confirm;//confirm confirm printf("\n\n\n\n\t\t You are using the sign out feature ");
printf("\n\n\n\n\t\t%d Confirm logout ?",user[find].account); fflush(stdin);// Empty input buffer
scanf("%c",&confirm); if(confirm=='y'||confirm=='Y'){
printf("\n\n\n\n\t\t Logging off %d",user[find].account); isLogout=1; }else{
printf("\n\n\n\n\t\t Cancel account cancellation %d, Return to the service interface ",user[find].account); isLogout=0; } }
// End exit void quit(){ system("cls");// Clear screen printf(" Exiting , Please wait ..."); exit(0);// Normal exit }
// Function interface void service(){ char choise; while(1){ system("cls");
printf("\n\n\n\n\t\tA, Check the balance "); printf("\n\n\t\tB, deposit "); printf("\n\n\t\tC, withdraw money ");
printf("\n\n\t\tD, transfer accounts "); printf("\n\n\t\tE, Change Password "); printf("\n\n\t\tF, cancellation ");
printf("\n\n\t\tG, Exit the system "); printf("\n\n\t\t Please select :"); fflush(stdin);// Clear screen
scanf("%c",&choise); switch(choise){ case 'a': case 'A':
selectMoney();break;// Check the balance case 'b': case 'B': saveMoney();break;// deposit case 'c':
case 'C': //printf("\n\n\t\t Perform withdrawal function ");break; getMoney();break;// withdraw money case 'd':
case 'D': transferMoney();break;// transfer accounts case 'e': case 'E':
printf("\n\n\t\t Perform the password modification function ");break; //updatePass();break;// Change Password case 'f': case
'F': logout(); if(isLogout==1){ return;// End the function directly } break;// cancellation case 'g': case
'G': quit();break;// Exit the system default: printf("\n\n\t\t Your input is incorrect , Please re-enter !");break; }
printf("\n\n\t\t press any key to continue "); getch();// Do not echo function , No need to press enter } } // Hide password void inputPass(char
pass[]){ int i=0; char ch; while(1){ ch=getch();// Do not echo function , No need to press enter
if(ch!='\r'){// Judge whether the input is enter if(ch!='\b'){// Judge whether the input is backspace
pass[i]=ch;// Assign the entered character to the second character of the password i position i++; printf("*"); }else{ if(i>0){ i--; printf("\b
\b"); } } }else{ break; } } pass[i]='\0'; printf("\n"); } // Registration interface void regist(){
system("cls");// Clear screen char rePass[7]; printf("\n\n\n\n\t\t\t\t enter one user name :");
// The user name to receive input using a string fflush(stdin);// Refresh character buffer gets(user[count].name);// Read string , Enter end
while(1){ while(1){ printf("\n\n\t\t\t\t Please input a password :"); fflush(stdin);// Empty input buffer
inputPass(user[count].pass); int
length=strlen(user[count].pass);// Calculate string length , Its return value is an integer if(length==6){ break;
}else{ printf("\n\n\t\t\t\t Incorrect password input ! Please enter 6 Bit cipher "); } }
printf("\n\n\t\t\t\t Please enter the password again :"); fflush(stdin);// Empty input buffer inputPass(rePass);
if(strcmp(rePass,user[count].pass)==0){ break; }else{
printf("\n\n\t\t\t\t The two passwords are inconsistent , Please re-enter "); } } account=account+1;
user[count].account=account; user[count].money=0; system("cls");// Clear screen
printf("\n\n\n\n\t\t\t\t login was successful \n");
printf("\n\n\t\t\t\t Your account number is :%d\n",user[count].account); if(count>=1){
printf("\n\n\t\t\t\t The previous registered account is :%d\n",user[count-1].account); } count++; } // login interface
void login(){ int zhanghao; int sign=0; int find; char loginPassword[7]; //1. Clear screen
system("cls"); //2. Tips Please enter the account number printf("\n\n\n\n\t\t\t\t Please enter the account number :"); //3. Get the entered account
scanf("%d",&zhanghao); //4. Compare the entered account with the account of each user in the user array for(int i=0;i<count;i++){
if(zhanghao==user[i].account){ sign=1;// take F Flag set to 1 find=i; break; } }
//5. If it matches , Please enter the password when prompted if(sign==1){ int j; for(j=1;j<=3;j++){
printf("\n\n\t\t Please input a password :"); inputPass(loginPassword);
if(strcmp(loginPassword,user[find].pass)==0){ printf("\n\n\t\t Login successful ");
printf("\n\n\t\t Enter the service interface "); service(); break; }else{ if(j==3){
printf("\n\n\t\t Password input error three times , Locked !"); break; } printf("\n\n\t\t Password error , Please re-enter !"); } }
}else{ printf("\n\n\t\t Account error "); } } // Initial interface void main(){ loading(); char ch;
while(1){ printf("\n\n\t\t\t\t\t\ta. User registration "); printf("\n\n\t\t\t\t\t\tb. User login ");
printf("\n\n\t\t\t\t\t\tc. Exit the system "); printf("\n\n\t\t\t\t\t\t Please select :");
fflush(stdin);// Clear character buffer , Carriage return scanf("%c",&ch); // Judge the input character if(ch=='a'||ch=='A') {
// Execute registration function regist(); //printf("\n\n\t\t Perform registration "); } else if(ch=='b'||ch=='B') {
// Execute login function login(); //printf("\n\n\t\t Execute login "); } else if(ch=='c'||ch=='C') {
//quit(); printf("\n\n\t\t Execute exit "); }else { printf("\n\n\t\t Incorrect input , Please re-enter !"); }
printf("\n\n\t\t press any key to continue ..."); getch();// Do not echo function , No need to press enter system("cls");// Clear screen } }
End of code , I hope it can help you .

Technology