C語言實(shí)現(xiàn)ATM系統(tǒng)程序的完整代碼
更新時(shí)間:2021年05月02日 08:48:49 作者:weixin_53391957
這篇文章主要介紹了C語言實(shí)現(xiàn)ATM系統(tǒng)程序的完整代碼,本文給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
實(shí)現(xiàn)效果如圖:

代碼如下:
#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;
//結(jié)點(diǎn)
typedef struct _Node
{
Person P; //客戶
struct _Node* next;
}Node;
Node* HeadNode = NULL;//鏈表頭
/*----------------函數(shù)--------------------*/
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歡迎進(jìn)入ATM銀行管理系統(tǒng)\n");
printf("\t\t 1. 注冊(cè)\n");
printf("\t\t 2. 登錄\n");
printf("\t\t 3. 系統(tǒng)幫助\n");
printf("\t\t 4. 查詢賬號(hào)\n");
printf("\t\t 5. 退出\n");
}
//注冊(cè)
void Register()
{
Node* NewNode = (Node*)malloc(sizeof(Node));
NewNode->next = NULL;
NewNode->P.money = 0;
printf("請(qǐng)輸入您的名字:");
scanf("%s", NewNode->P.name);
printf("請(qǐng)輸入您的密碼:");
scanf("%s", NewNode->P.password);
char Password[7];
printf("請(qǐng)?jiān)俅屋斎肽拿艽a:");
scanf("%s", Password);
for (int i = 1; i < 4; i++)
{
if (strcmp(NewNode->P.password, Password) != 0)
{
printf("您輸入的密碼有誤,還有%d次機(jī)會(huì).\n", 3 - i);
printf("請(qǐng)?jiān)俅屋斎肽拿艽a:");
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恭喜你已經(jīng)成功注冊(cè)賬戶,以下是您的賬戶信息.\n");
printf("\t\t\t\t姓名:%s\n", NewNode->P.name);
printf("\t\t\t\t賬戶:%s\n", NewNode->P.account);
printf("\t\t\t\t余額:%.2f\n", NewNode->P.money);
getch();
return 1;
}
}
printf("您的賬號(hào)已被鎖定,請(qǐng)稍后再試.");
return 1;
}
//取款
void DrawMoney(Node* pNode)
{
Node* mNode = pNode;
float Money = 0;
printf("歡迎進(jìn)入ATM銀行管理系統(tǒng)\n");
printf("請(qǐng)選擇你取款金額\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("請(qǐng)存取您的金額:");
scanf("%f", &Money);
mNode->P.money = mNode->P.money + Money;
return mNode;
}
//轉(zhuǎn)賬
void Transfer(Node* pNode)
{
Node* TNode = HeadNode;
char Account[20];
printf("請(qǐng)輸入轉(zhuǎn)賬的號(hào)碼:");
scanf("%s", Account);
while (TNode != NULL)
{
if (strcmp(TNode->P.account, Account) != 0)
{
TNode = TNode->next;
continue;
}
else
{
float Money = 0;
printf("請(qǐng)輸入您要轉(zhuǎn)賬的金額:");
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("歡迎進(jìn)入ATM銀行管理系統(tǒng)\n");
printf("請(qǐng)選擇以下服務(wù):\n");
printf("1.取款\t\t2.查詢\n");
printf("3.存款\t\t4.轉(zhuǎn)賬\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("請(qǐng)輸入您的卡號(hào):");
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("請(qǐng)輸入您的密碼:");
scanf("%s", P_password);
if (strcmp(P_password, pNode->P.password) != 0)
{
printf("您輸入的密碼有誤,還有%d次機(jī)會(huì).\n", 3 - i);
}
else
{
system("cls");
LoginMenu(pNode);
return 1;
}
}
printf("\n對(duì)不起,您輸入的密碼有誤,請(qǐng)重新登錄.\n");
system("pause");
return 1;
}
}
return 1;
}
//系統(tǒng)幫助信息
void Help()
{
system("cls");
printf( "\n\n\n\n\t——————————-----—---——ATM系統(tǒng)幫助----------------------------------------\n"
"\t1、初始界面:客戶插卡前或者退卡后ATM顯示的界面,提示客戶插卡操作及銀行廣告.\n"
"\t2、身份認(rèn)證:需要客戶插入銀行卡后輸入密碼來驗(yàn)證所有權(quán).\n"
"\t3、吞卡:客服若連續(xù)輸入密碼3次錯(cuò)誤后,則將卡吞入ATM內(nèi).\n"
"\t4、賬戶:賬戶由銀行卡的卡號(hào)、密碼、銀行系統(tǒng)用戶信息組成.\n"
"\t5、業(yè)務(wù)操作:由查詢余額、取款、存款、轉(zhuǎn)賬、取卡等事項(xiàng)組成.\n"
"\t6、查詢余額:顯示該賬戶中剩余金額.\n"
"\t7、取款:根據(jù)客戶輸入的金額從賬戶中扣除相應(yīng)的金額,客戶可以提取相應(yīng)數(shù)額的現(xiàn)金.\n"
"\t8、存款:客戶存入現(xiàn)金,賬戶根據(jù)現(xiàn)金數(shù)額增加剩余金額.\n"
"\t9、轉(zhuǎn)賬:客戶輸入另外一個(gè)賬戶號(hào)碼和金額,從本賬戶的余額中減去該金額,增加到那個(gè)賬號(hào)中.\n"
"\t10、打印憑條:憑條由日期,銀行卡的卡號(hào),交易流水號(hào)組成.\n"
"\t11、取卡:客戶取回銀行卡.\n"
"\t————————————————-------------------------------------------------------\n"
);
getch();
return 1;
}
//查詢賬號(hào)
void FindAccount(Node* pNode)
{
Node* FNode = pNode;
char AccountName[7];
printf("請(qǐng)輸入賬號(hào)姓名:");
scanf("%s", AccountName);
while (FNode != NULL)
{
if (strcmp(AccountName, FNode->P.name) != 0)
{
FNode = FNode->next;
continue;
}
else
{
printf("該姓名的賬戶為:%s", FNode->P.account);
return 1;
}
}
printf("抱歉!該姓名未注冊(cè)賬號(hào).");
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;
}
到此這篇關(guān)于C語言實(shí)現(xiàn)ATM系統(tǒng)程序的完整代碼的文章就介紹到這了,更多相關(guān)c語言ATM系統(tǒng)程序內(nèi)容請(qǐng)搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
C++實(shí)現(xiàn)教工考勤信息管理系統(tǒng)
這篇文章主要為大家詳細(xì)介紹了C++實(shí)現(xiàn)教工考勤信息管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2022-05-05
C++ 數(shù)據(jù)結(jié)構(gòu)鏈表的實(shí)現(xiàn)代碼
這篇文章主要介紹了C++ 數(shù)據(jù)結(jié)構(gòu)鏈表的實(shí)現(xiàn)代碼的相關(guān)資料,需要的朋友可以參考下2017-01-01
C++入門基礎(chǔ)之命名空間、輸入輸出和缺省參數(shù)
C++入門基礎(chǔ)篇的內(nèi)容為C++的基本特性,只有在掌握C++的基本特性后,是進(jìn)入后面類和對(duì)象學(xué)習(xí)的基礎(chǔ),下面這篇文章主要給大家介紹了關(guān)于C++入門基礎(chǔ)之命名空間、輸入輸出和缺省參數(shù)的相關(guān)資料,需要的朋友可以參考下2023-01-01
C++實(shí)現(xiàn)掃雷小游戲(控制臺(tái)版)
這篇文章主要為大家詳細(xì)介紹了C++實(shí)現(xiàn)控制臺(tái)版的掃雷小游戲,文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下2020-03-03
高效實(shí)現(xiàn)整型數(shù)字轉(zhuǎn)字符串int2str的方法
下面小編就為大家?guī)硪黄咝?shí)現(xiàn)整型數(shù)字轉(zhuǎn)字符串int2str的方法。小編覺得挺不錯(cuò)的,現(xiàn)在就分享給大家,也給大家做個(gè)參考。一起跟隨小編過來看看吧2017-03-03

