ATM源码

package atm;//张秋亮,信1705-3,20173529

public class Account

{

    private String accountID;

    private String accountname;

    private String operatedate;

    private int operatetype;

    private String accountpassword;

    private int accountbalance;

    private int amount;

 

    public void setaccountID(String a)

    {

        accountID=a;

    }

    public void setaccountname(String b)

    {

        accountname=b;

    }

    public void setoperatedate(String c)

    {

        operatedate=c;

    }

    public void setoperatetype(int d)

    {

        operatetype=d;

    }

    public void setaccountpassword(String e)

    {

        accountpassword=e;

    }

    public void setaccountbalance(int f)

    {

        accountbalance=f;

    }

    public void setamount(int g)

    {

        amount=g;

    }

   

   

    public String getaccountID()

    {

        return accountID;

    }

    public String getaccountname()

    {

        return accountname;

    }

    public String getoperatedate()

    {

        return operatedate;

    }

    public int getoperatetype()

    {

        return operatetype;

    }

    public String getaccountpassword()

    {

        return accountpassword;

    }

    public int getaccountbalance()

    {

        return accountbalance;

    }

    public int getamount()

    {

        return amount;

    }

    public Account() {}

    public void menu(int i)

    {

       

        System.out.println("***************************************************************");

        System.out.println("        欢迎"+i+"使用中国工商银行自助柜员系统");

        System.out.println("***************************************************************");

        System.out.println("                           输入您的密码:");

        System.out.println("***************************************************************");

    }

    public void menu0()

    {

        System.out.println("***************************************************************");

        System.out.println("                   欢迎使用中国工商银行自助柜员系统");

        System.out.println("***************************************************************");

        System.out.println("                           输入您的账号:");

        System.out.println("***************************************************************");

    }

    public void menu1(int i)

    {

        System.out.println("***************************************************************");

        System.out.println("        欢迎"+i+"(账户名称)使用中国工商银行自助柜员系统");

        System.out.println("***************************************************************");

        System.out.println("                           1.存款");

        System.out.println("                           2.取款");

        System.out.println("                           3.转账汇款");

        System.out.println("                           4.修改密码");

        System.out.println("                           5.查询余额");

        System.out.println("***************************************************************");

    }

    public void menu2(int i)

    {

        System.out.println("***************************************************************");

        System.out.println("欢迎"+i+"(账户名称)使用中国工商银行自助柜员系统");

        System.out.println("****************************************************************");

        System.out.println("请输入存款金额;");

        System.out.println("****************************************************************");

    }

    public void cun(double m,int i)

    {

        System.out.println("***************************************************************");

        System.out.println("欢迎"+i+"使用中国工商银行自助柜员系统");

        System.out.println("****************************************************************");

        System.out.println("当前账户存款操作成功。");

        System.out.println("当前账户余额为:"+m+"元");

        System.out.println("****************************************************************");

    }

    public void qu(int i)

    {

        System.out.println("***************************************************************");

        System.out.println("欢迎"+i+"使用中国工商银行自助柜员系统");

        System.out.println("****************************************************************");

        System.out.println("当前账户每日可以支取 2 万元。");

        System.out.println("1. 100");

        System.out.println("2. 500");

        System.out.println("3. 1000");

        System.out.println("4. 1500");

        System.out.println("5. 2000");

        System.out.println("6. 5000");

        System.out.println("7. 其他金额 ");

        System.out.println("8. 退卡 ");

        System.out.println("9. 返回");

        System.out.println("****************************************************************");

    }

    public void zhuan(int i)

   

    {

        System.out.println("*************************************************************** ");

        System.out.println("欢迎 "+i+"使用中国工商银行自助柜员系统 ");

        System.out.println("**************************************************************** ");

        System.out.println("请输入转账账户; ");

        System.out.println("**************************************************************** ");

    }

    public void jine(int i)

    {

        System.out.println("*************************************************************** ");

        System.out.println("欢迎"+i+" 使用中国工商银行自助柜员系统 ");

        System.out.println("*************************************************************** ");

        System.out.println("请输入转账金额; ");

        System.out.println("*************************************************************** ");

    }

    public void mima(int i)

    {

        System.out.println("*************************************************************** ");

        System.out.println("欢迎"+i+" 使用中国工商银行自助柜员系统 ");

        System.out.println("*************************************************************** ");

        System.out.println("请输入当前密码: ");

        System.out.println("请输入修改密码: ");

        System.out.println("请输入确认密码: ");

        System.out.println("*************************************************************** ");

    }

 

 

}

 

Account.java

package atm;

import java.util.Scanner;

import java.util.ArrayList;

public class AccountManager

{

 

    public static void main(String[] args) {

        Account account =  new Account ();

        double m=0;

        int i=0;

        int k=0;

        int j=0;

        String l="";

        Scanner in=new Scanner(System.in);

        boolean ture = false;

        while(!ture)

        {

        do

        {

        account.menu0();

        i=in.nextInt();

        while(i<10000000||i>99999999)

        {

            System.out.println("                           该卡不是工行卡              ");

            System.out.println("                           重新输入您的账号");

            i=in.nextInt();

        }

        account.menu(i);

      

        for(k=0;k<3;k++)

        {

            j=in.nextInt();

            if(j>100000&&j<999999)

               {

                 

                  k=5;

                  break;

               }

            else if(j<100000||j>999999)

                {

                System.out.println("密码输入错误");   

                }

           else if(j==888888)

                {

                System.out.println("密码输入错误");

                }   

        }

        if(k==3)

            {

            System.out.println("该账号三次录入密码错误,该卡已被系统没收,请与工行及时联系处理");

            }       

    }while(k!=5);

       

       

        do

        {

        account.menu1(i);

        l=in.next();

        switch(l){

        case "1":   

        {

            account.menu2(i);

            m=in.nextDouble();

            while(m<0||m-(int)m>0.00001)

                {

                System.out.println("输入金额有误");

                account.menu2(i);

                m=in.nextInt();

                }

            account.cun(m,i);  

        };break;

        case "2":

            {

                account.qu(i);

                int n;

                n=in.nextInt();

                switch(n)

                {

                case 1:

                    {

                        if(m<100)

                            System.out.println("账户余额不足");

                        else

                            m=m-100;

                    };break;

                case 2:{

                    if(m<500)

                        System.out.println("账户余额不足");

                    else

                        m=m-500;

                };break;

                case 3:{

                    if(m<1000)

                        System.out.println("账户余额不足");

                    else

                        m=m-1000;

                };break;

                case 4:{

                    if(m<1500)

                        System.out.println("账户余额不足");

                    else

                        m=m-1500;

                };break;

                case 5:{

                    if(m<2000)

                        System.out.println("账户余额不足");

                    else

                        m=m-2000;

                };break;

                case 6:{

                    if(m<5000)

                        System.out.println("账户余额不足");

                        m=m-5000;

                };break;

                case 7:{

                    System.out.println("*************************************************************** ");

                    System.out.println("欢迎"+i+" 使用中国工商银行自助柜员系统");

                    System.out.println("**************************************************************** ");

                    System.out.println("请输入取款金额:");

                    System.out.println("**************************************************************** ");

                    int jin;

                    jin=in.nextInt();

                    if(m<jin)

                        System.out.println("账户余额不足");

                    else

                    m=m+jin;

                };break;

                case 8:account.menu0();;break;

                case 9:account.menu1(i);break;

                }

            }

        case "3":{

            account.zhuan(i);

            int zhanghu;

            zhanghu=in.nextInt();

            account.jine(i);

            int jine;

            jine=in.nextInt();

            if(m<jine)

                System.out.println("账户余额不足");

            else

            {

                System.out.println("*************************************************************** ");

                System.out.println("欢迎"+i+"使用中国工商银行自助柜员系统 ");

                System.out.println("**************************************************************** ");

                System.out.println("请确认是否向"+zhanghu+"转账"+jine+"元");

                System.out.println("当前账户余额为:"+(m-jine)+" 元 ");

            }

               

        };break;

        case "4":{

            account.mima(i);

            int ymi,nmi,nmi2;

            ymi=in.nextInt();

            nmi=in.nextInt();

            nmi2=in.nextInt();

            if(ymi==j)

            {

                if(nmi==nmi2)

                {

                    System.out.println("***************************************************************");

                    System.out.println("欢迎 "+i+"使用中国工商银行自助柜员系统 ");

                    System.out.println("***************************************************************");

                    System.out.println("当前账户密码修改成功 ");

                    System.out.println("***************************************************************");

                }

                else

                    System.out.println("修改密码与确认密码不一致");

            }

            else

                System.out.println("当前密码录入错误");

        };break;

        case "5":System.out.println("当前余额:"+m);break;

        }

       

        }while(l.charAt(0)!='q');

        }

    }

}

AccountManager.java

 

posted @ 2018-09-24 19:10  ZQL2017  阅读(256)  评论(1编辑  收藏  举报