zoukankan      html  css  js  c++  java
  • 模拟ATM机功能(C语言)

    /*
    fuction:模拟ATM机存取功能
    date:2014/8/20
    by:zhouhaiou
    */

    #include <stdio.h>
    #include <string.h>
    #include <math.h>
    int money=100000;

    void query();
    void transf();

    void welcome()//欢迎界面
    {
    printf(" *********************************************** ");
    printf(" * * ");
    printf(" * ---欢迎光临LOL自助银行--- * ");
    printf(" * * ");
    printf(" * 用户名:F10 版本14.08.20 * ");
    printf(" * * ");
    printf(" * 制作人:zhouhaiou * ");
    printf(" * * ");
    printf(" * 客服电话:95599 * ");
    printf(" *********************************************** ");
    printf(" ");

    }


    int password(char str[])//验证password
    {
    char ps1[]="123.";
    char ps2[20]="0";
    int i=1;
    printf(" ***温馨提示*** 密码只能输入3次! ");
    printf(" ");
    printf(" ");
    printf("请输入你的密码:");
    scanf("%s",ps2);
    do
    {
    if(strcmp(ps1,ps2)!=0)
    {
    printf(" 密码错误! 请重新输入密码:");
    scanf("%s",ps2);
    i++;
    }
    else
    {
    system("cls");
    return 1;
    break;
    }

    }while(i<3);
    if(i>=3)
    {
    if(strcmp(ps1,ps2)!=0)
    {
    printf("你输入密码错误次数超过3次,不能使用本系统,请联系相关管理员! ");
    getch();
    return 0;
    }
    else
    {
    system("cls");
    return 1;
    }
    }

    }

    void menu(int num)//主菜单
    {
    int choice=0,money1=0,money2=0;
    printf("*******请选择你需要的服务:***** ");
    printf("* * ");
    printf("* 1.查询 2.取款 * ");
    printf("* * ");
    printf("* 3.存款 4.转账 * ");
    printf("* * ");
    printf("* 5.退出 * ");
    printf("* * ");
    printf("******************************** ");
    printf(" ");
    scanf("%d",&choice);
    while(choice!=5)
    {
    switch(choice)
    {
    case 1:system("cls");
    query(choice);
    system("pause");
    break;
    case 2:system("cls");
    qukuan(money1);
    system("pause");
    break;
    case 3: system("cls");
    cunkuan(money2);
    system("pause");
    break;
    case 4: system("cls");
    transf();
    system("pause");
    break;
    case 5: printf("退出");
    break;
    }
    system("cls");
    printf("*******请选择你需要的服务:***** ");
    printf("* * ");
    printf("* 1.查询 2.取款 * ");
    printf("* * ");
    printf("* 3.存款 4.转账 * ");
    printf("* * ");
    printf("* 5.退出 * ");
    printf("* * ");
    printf("******************************** ");
    printf(" ");
    scanf("%d",&choice);
    }
    system("cls");
    printf("欢迎你的下次光临,系统正在退出..... ");
    getch();

    }

    void query(int num)//查询余额
    {
    int choice=0;
    printf("1.人民币 2.外币 ");
    scanf("%d",&choice);
    system("cls");
    switch(choice)
    {
    case 1:printf("你的余额为:%d元 ",money);
    break;
    case 2:printf("your money:$%d ",money);
    break;
    }
    }

    int qukuan(int num)//取款
    {
    int money1=0;
    printf("请输入你需要取走的金额:");
    scanf("%d",&money1);
    do
    {
    if(money1>money)
    {
    printf("余额不足,请重新输入:");
    scanf("%d",&money1);
    }
    else
    {
    system("cls");
    printf("系统正在处理,请稍后..... ");
    system("pause");
    system("cls");
    break;
    }
    }while(money1<money);
    printf("恭喜你成功取走%d元! ",money1);
    money=money-money1;
    }

    int cunkuan(int num)//存款
    {
    int money2=0;
    printf("请输入你要存入的金额:");
    scanf("%d",&money2);
    system("cls");
    printf("系统正在处理中,请稍候..... ");
    system("pause");
    system("cls");
    money=money+money2;
    printf("存入%d成功! ",money2);

    }

    void transf()//转账
    {
    printf("请见谅,此功能系统正在维护..... ");
    }

    void main()
    {
    char psword[10];
    int choice=0,flag=0;
    welcome();
    flag=password(psword);
    if(flag==1)
    {
    menu(choice);
    }
    else
    {
    return;
    }

    }

  • 相关阅读:
    codeforces 557D Vitaly and Cycle
    CF312 div2 CDE
    关于bolg
    codeforces 487C Prefix Product Sequence (模逆元+构造)
    【HDU2795】Billboard(线段树)
    【HDU1394】Minimum Inversion Number(线段树)
    【HDU1754】I Hate It(线段树)
    【HDU1514】Stars(树状数组)
    【CDOJ931】Car race game(树状数组求逆序)
    【HDU1166】敌兵布阵(树状数组或线段树)
  • 原文地址:https://www.cnblogs.com/zhouhaiou/p/3931102.html
Copyright © 2011-2022 走看看