| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 1383 人关注过本帖
标题:在做一个C语言的ATM系统,管理员操的三种功能不会写,在线求,等急
只看楼主 加入收藏
wwq871764008
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2020-6-15
收藏
 问题点数:0 回复次数:0 
在做一个C语言的ATM系统,管理员操的三种功能不会写,在线求,等急
#include<stdio.h>
#include<stdlib.h>
#include<string>

struct BankUser{
    char id[20];
    char sname[20];
    char gender[20];
    char age[20];
    char pwd[50];
} BankUser[3]={{"a","wwq","男","20","010406"},{"b","wb","男","19","123456"},{"c","zyq","女","19","011010"}};


struct IDMIN{
    char sno[20];
    char name[20];
    char pwds[20];
} IDMIN[2]={{"1","ad","123"},{"2","ap","456"}};


void welcome();
void BankUserLogin();
void IDMINLogin();
void BankUsermenu(char id[]);
void IDMINmenu(char sno[]);
void BankUserInfo(char id[]);
int Money;
int DrawMoney;
int Deposit;
FILE *fp;
void open(char id[]);
void save(char id[]);



void welcome(){          //欢迎界面

    printf("------欢迎登录xxx银行ATM系统------\n");
    printf("------------1 用户登录------------\n");
    printf("-----------2 管理员登录-----------\n");
    printf("------------0 退出系统------------\n");
}

void open(){
    if((fp = fopen("DrawMoney.txt","r"))==NULL){
            printf("FILE cannot open!");
            exit(0);
        }
        fscanf(fp,"%d",&Money);
        fclose(fp);
}


void save(){
    if((fp = fopen("DrawMoney.txt","w"))==NULL){
        printf("FILE cannot open!\n");
        exit(0);
    }
    fprintf(fp,"%d",Money);
    fclose(fp);
}



void main(){
    while(1){
    welcome();
    int op;
    scanf("%d",&op);
        switch(op){
            case 1:       //用户登录
                BankUserLogin();
                break;
            case 2:       //管理员登录
                IDMINLogin();
                break;
            case 0:       //退出系统
                printf("退出系统\n");
                exit(0);
                break;
            default:
                printf("输入有误请重新输入\n");
                break;
    }

    }
}
   

void BankUserLogin(){      //用户登录
    char id[20];
    char pwd[50];
        while(1){
        printf("请插卡(按0退出):\n");
        scanf("%s",id);
        printf("请输入密码(按0退出):\n");
        scanf("%s",pwd);

        int i, flag=0;
        for(i=0;i<3;i++){
            if(strcmp(BankUser[i].id,id)==0){
                if(strcmp(BankUser[i].pwd,pwd)==0){
                BankUsermenu(id);
                flag=1;
                printf("\n");

                }
            }
        }

        if(!flag){
            printf("卡不正确或密码错误(按0退出)\n");
        int op;
        printf("是否重新登录:(1 继续  0 退出)\n");
        scanf("%d",&op);
        if(op){

        }else{
            printf("回到主界面\n");
            return;
        }
        }
    }
}


void BankUsermenu(char id[]){           //用户界面
   
        while(1){
        printf("------------------\n");
        printf("用户界面\n");
        printf("1.查看用户信息\n");
        printf("2.存款\n");
        printf("3.取款\n");
        printf("4.查询余额\n");
        printf("0.退出登录\n");
   
        int op;
        scanf("%d",&op);
        switch(op){
            case 1:       //查看客户信息
                BankUserInfo(id);
                break;
            case 2:       //存款
                printf("请输入存款金额:\n");
                scanf("%d",&Deposit);
                Money += Deposit;
                printf("您的余额为:%d\n",Money);
                break;
            case 3:       //取款
                printf("请输入取款金额:\n");
                scanf("%d",&DrawMoney);
                if(Money > DrawMoney){
                    Money -= DrawMoney;
                    printf("取款成功\n");
                }else{
                    printf("余额不足,取款失败\n");
                }
                break;
            case 4:       //查询余额
                printf("您的余额有:%d\n",Money);
                break;
            case 0:       //退出系统
                printf("退出登录\n");
            return;
            break;
            default:
                printf("输入有误请重新输入\n");
                break;
        }
    }
}


void BankUserInfo(char id[]){     //查看客户信息
    int j;
    struct BankUser b;
    for(j=0;j<3;j++){
        if(strcmp(BankUser[j].id,id)==0){
            b=BankUser[j];
            break;
        }
    }
   
    printf("用户信息界面");
    printf("------------------\n");
    printf("id: %s\n",b.id);
    printf("姓名: %s\n",b.sname);
    printf("性别: %s\n",b.gender);
    printf("年龄: %s\n",b.age);
    printf("密码: %s\n",b.pwd);
    printf("------------------\n");

}

void IDMINLogin(){        //管理员登录
        char sno[20];
        char pwds[20];
        while(1){
            printf("请输入账号(按0退出):\n");
            scanf("%s",sno);
            printf("请输入密码(按0退出):\n");
            scanf("%s",pwds);
   
            int j, flag=0;
                for(j=0;j<2;j++){
                if(strcmp(IDMIN[j].sno,sno)==0){
                    if(strcmp(IDMIN[j].pwds,pwds)==0){
                    IDMINmenu(sno);
                    flag=1;
                    printf("\n");

                }
            }
        }

        if(!flag){
            printf("账号或密码错误(按0退出)\n");


        int op;
        printf("是否重新登录:(1 继续  0 退出)\n");
        scanf("%d",&op);
        if(op){

        }else{
            printf("回到主界面\n");
            return;
        }
        }
    }
}


void IDMINmenu(char sno[]){             //管理员界面
    while(1){
        printf("管理员界面\n");
        printf("1.查询交易记录\n");
        printf("2.冻结账户\n");
        printf("3.解冻账户\n");
        printf("0.退出登录\n");
        printf("------------------\n");

            int op;
            scanf("%d",&op);
            switch(op){

                    case 1:        //查询交易记录
                        
                break;
                    case 2:        //冻结账户
                        
                break;

                    case 3:        //解冻账户
                    
                break;

                    case 0:        //退出登录
                        printf("退出登录\n");
                    return;
                break;
                    default:
                    printf("输入有误请重新输入\n");
                break;
            }
    }
}
搜索更多相关主题的帖子: printf char 退出 void break 
2020-06-15 11:26
快速回复:在做一个C语言的ATM系统,管理员操的三种功能不会写,在线求,等急
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.017716 second(s), 10 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved