• java银行自主柜员程序设计


    /*
    * 信1705-2 20173611 谢培龙
    */
    package 银行自主管理;
    import java.util.Scanner;
    //模仿银行自助存取一体机(ATM)
    public class TestUser4 {
    public static int end=1;
    public static void main(String[] args) throws InterruptedException {
    Account comd[]=new Account[5];
    comd[0]=new Account(20173611,"谢培龙","123456",1000);
    comd[1]=new Account(20173612,"李某","234567",2000);
    comd[2]=new Account(20173613,"王某","345678",3000);
    comd[3]=new Account(20173614,"刘某","456789",2000);
    comd[4]=new Account(20173615,"田某","567890",1500);
    while(true)//输出初始界面
    {
    if(end==0)
    {
    System.out.println("谢谢使用,再见!");
    return ;
    }
    System.out.println("*********************************************************************:");
    System.out.println(" 欢迎使用 中国工商银行自主柜员服务:");
    System.out.println("*********************************************************************:");

    System.out.println("请插入您的银行卡:");
    System.out.println("已插入卡,插入后请不要移动您的卡,谢谢配合!");
    System.out.println("正在识别请稍后");
    System.out.println("**********************************************************************");
    for(int i=0;i<5;i++)
    {
    Thread.sleep(100);
    System.out.print("\t");
    }
    System.out.println("\n卡识别正确,进入业务操作界面!");
    int i;
    for(i=0;i<comd.length;i++)
    {
    boolean flag=comd[i].checkPassword();
    if(flag)
    {
    System.out.println("密码正确:进入操作界面");
    comd[i].operateing();
    }
    }
    if(i==comd.length)
    {
    System.out.println("该用户不存在:");
    }
    }
    }


    }
    @SuppressWarnings("unused")// 账户记录
    class Account{
    private int accountid;//账户ID
    private String accountname;//账户姓名
    private String password;//账户密码
    private double money; //账户余额
    public Account(int id,String name,String password,double money)//返回原值
    {
    this.accountid=id;
    this.accountname=name;
    this.password=password;
    this.money=money;
    }
    public String getpassword()
    {
    return this.password;
    }
    public int getId()//利用get() 获得账户
    {
    return this.accountid;
    }
    public boolean checkMoney(int m)//取款
    {
    int i;
    for(i=0;i<5;i++)
    {
    if(m>money)
    {
    System.out.println("您的账户可用余额不够您的取款金额,请重新输入您的取款金额!");
    System.out.print("请重新输入您的取款金额:");
    Scanner scn2=new Scanner(System.in);
    m=scn2.nextInt();
    }
    else
    {
    this.money-=m;
    System.out.println("恭喜您,取款成功!");
    return true;
    }
    }
    if(i==5)
    return false;
    return false;
    }
    public boolean saveMoney(int m)
    {
    try
    {
    Thread.sleep(100);
    System.out.print("\t!");
    }catch(Exception e)
    {
    e.printStackTrace();
    }
    this.money+=m;
    System.out.println("恭喜您,存款成功!");
    return true;
    }
    public void search()
    {
    System.out.println("账号:"+this.accountid+",姓名:"+this.accountname+"当前可用余额:"+this.money+"元");
    }
    @SuppressWarnings("unuesd")
    public boolean checkPassword()
    {
    System.out.println(" ");
    System.out.println(" ");
    System.out.println("*********************************************************************:");
    System.out.println("欢迎使用谢培龙 中国工商银行自主柜员服务:");
    System.out.println("*********************************************************************:");
    int i;
    System.out.println("请输入密码:");
    for(i=0;i<3;i++)
    {

    Scanner scn=new Scanner(System.in);
    String passwords=scn.nextLine();
    if(password.equals(passwords))
    return true;
    else
    {
    System.out.println("密码错误,请重新输入密码:");
    continue;
    }

    }
    if(i==3)
    {
    System.out.println("该账号三次录入密码错误,该卡已被系统没收,请与工行及时联系处理!");
    }
    return false;
    }
    public void operateing()
    {
    menu();
    while(true)
    {
    Scanner scn=new Scanner(System.in);
    System.out.print("请输入你的选择(0-3):");
    int chioce=scn.nextInt();
    switch(chioce)
    {
    case 1:System.out.print("请输入存款金额:");
    Scanner scn1=new Scanner(System.in);
    int money1=scn1.nextInt();
    saveMoney(money1);break;
    case 2:System.out.print("请输入取款金额:");
    Scanner scn2=new Scanner(System.in);
    int money2=scn2.nextInt();
    checkMoney(money2);break;
    case 3:search();break;
    case 0:System.out.println("退出系统,请收好您的卡,再见!");
    }
    }
    }
    public static void menu()
    {System.out.println("**********************************************************");
    System.out.println("\t欢迎使用ATM自助银行服务,操作中请保管好您随身携带的物品及密码的安全!");
    System.out.println("\t------------------");
    System.out.println("\t [1.存款]");
    System.out.println("\t [2.取款]");
    System.out.println("\t [3.余额]");
    System.out.println("\t [0.退卡]");
    System.out.println("\t------------------");
    System.out.println("************************************************************");
    }
    }

  • 相关阅读:
    [转]laravel 4之视图及Responses
    Laravel 安装指南
    [转]CodeIgniter与Zend Acl结合实现轻量级权限控制
    OSCHina技术导向:Java电子商务平台OFBiz
    OSCHina技术导向:Java开源QQ工具iQQ
    OSCHina技术导向:web内容管理系统Magnolia
    OSCHina技术导向:Java轻量web开发框架——JFinal
    OSCHina技术导向:Java模板引擎velocity
    OSCHina技术导向:Java全文搜索框架Lucene
    OSChina技术导向:Java图表框架JFreeChart
  • 原文地址:https://www.cnblogs.com/1983185414xpl/p/9696775.html
Copyright © 2020-2023  润新知