ATM

Posted nclong

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ATM相关的知识,希望对你有一定的参考价值。

Account.java类

package ATM模拟;
import java.io.PrintWriter;
import java.io.BufferedReader;
import java.util.StringTokenizer;
import java.io.IOException;
import java.text.SimpleDateFormat;  
import java.util.Date;  
public class Account {
 String accountID;//用于存储学生的用户账号(由八位数字组成)。
 String accountname;//用于存储账户的名称。
 String operatedate;//用于存储操作的时间,由十位字符组成,显示格式为“2018-09-20”。   
 int operatetype;//用于存储操作账户的类型,具体描述为“1”表示存款,“2”表示取款,“3”表示转
 String accountpassword;//用于用户密码,由六位数字组成。
 int accountbalance;//用于存储账户余额,缺省为0。
 int amount;//表示操作流水金额。
 public Account() {
  accountID="20173575";
  accountname="WOSHINPC";
  operatedate="2017-9-23";
  operatetype=0;
  accountpassword="201735";
  accountbalance=0;
  amount=0;
 }
 public Account(String accountID, String accountname, String operatedate, int operatetype, String accountpassword,
   int accountbalance, int amount) {
  this.accountID = accountID;
  this.accountname = accountname;
  this.operatedate = operatedate;
  this.operatetype = operatetype;
  this.accountpassword = accountpassword;
  this.accountbalance = accountbalance;
  this.amount = amount;
 }
 
 public Account(String accountID, String accountname, String accountpassword, int accountbalance) {
  this.accountID = accountID;
  this.accountname = accountname;
  this.accountpassword = accountpassword;
  this.accountbalance = accountbalance;
 }
 
 public Account(String accountID, String accountname, String operatedate, int operatetype, int amount) {
  super();
  this.accountID = accountID;
  this.accountname = accountname;
  this.operatedate = operatedate;
  this.operatetype = operatetype;
  this.amount = amount;
 }
 public String getAccountID() {
  return accountID;
 }
 public void setAccountID(String accountID) {
  this.accountID = accountID;
 }
 public String getAccountname() {
  return accountname;
 }
 public void setAccountname(String accountname) {
  this.accountname = accountname;
 }
 public String getOperatedate() {
        long timemillis = System.currentTimeMillis();
      SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");  
      operatedate=df.format(new Date(timemillis));  
  return operatedate;
 }
 public void setOperatedate(String operatedate) {
  this.operatedate = operatedate;
 }
 public int getOperatetype() {
  return operatetype;
 }
 public void setOperatetype(int operatetype) {
  this.operatetype = operatetype;
 }
 public String getAccountpassword() {
  return accountpassword;
 }
 public void setAccountpassword(String accountpassword) {
  this.accountpassword = accountpassword;
 }
 public int getAccountbalance() {
  return accountbalance;
 }
 public void setAccountbalance(int accountbalance) {
  this.accountbalance = accountbalance;
 }
 public int getAmount() {
  return amount;
 }
 public void setAmount(int amount) {
  this.amount = amount;
 }
 public void writeAccount(PrintWriter out){
 out.println(getAccountID()+"|"+getAccountname() +"|"+getAccountpassword()+"|"+getAccountbalance()); 
 }
 public void readAccount(BufferedReader in)throws IOException{
  String ss=in.readLine();
  StringTokenizer St=new StringTokenizer(ss,"|");
  accountID=St.nextToken();
  accountname=St.nextToken();
  accountpassword=St.nextToken();
  accountbalance=Integer.parseInt(St.nextToken());
 }
 public void write1Account(PrintWriter out){
 out.println(getAccountID()+"|"+getAccountname() +"|"+getOperatedate()+"|"+getOperatetype()+"|"+getAmount()); 
 }
 public void read1Account(BufferedReader in)throws IOException{
  String ss=in.readLine();
  StringTokenizer St=new StringTokenizer(ss,"|");
  accountID=St.nextToken();
  accountname=St.nextToken();
  operatedate=St.nextToken();
  operatetype=Integer.parseInt(St.nextToken());
  amount=Integer.parseInt(St.nextToken());
 }
}
 
 
AccountManager.java类
package ATM模拟;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.PrintWriter;
import java.io.FileWriter;
import java.io.FileReader;
import java.io.IOException;
import java.util.Scanner;
import java.util.StringTokenizer;
import java.io.File;
import java.io.FileNotFoundException;
public class AccountManager {
 private Account[] a1 = new Account[5];
 private String Infor = "accountinformation.txt";
 private String List = "accountlist.txt";
 private String Today = "2018-9-20";
public void login()throws IOException{
 System.out.println("***************************************************************");
 System.out.println("              欢迎使用中国工商银行自动柜员系统");
 System.out.println("***************************************************************");
 System.out.println("                    请输入您的账号:");
 Scanner sc = new Scanner(System.in);
 int a= 5;
 String b = sc.next();
 while(a>3){
  for(int i=0;i<5;i++){
   if(a1[i].getAccountID().equals(b))
   {a=i;break;
   }
   
   if(a==5){
    System.out.println(" 该卡不是工行卡!");
    login();
   }
   else{
    aword(a);
   }
  }
 }
}
public void aword(int a)throws IOException{
 System.out.println("***************************************************************");
 System.out.println("   欢迎"+a1[a].getAccountname()+"使用中国工商银行自助柜员系统");
 System.out.println("***************************************************************");
 System.out.println("                    请输入您的密码:");
   int time= 0;
   Scanner sc = new Scanner (System.in);
           while(time<3){
                String saving = sc.nextLine();
                if(a1[a].getAccountpassword().equals(sc))
                     System.out.println("密码录入错误");
                 else
                    break;
                 time++;
             }
             if(time==3)
              login();
             else
              serviceAll(a);
        }
public void serviceAll(int a)throws IOException{
    System.out.println("***************************************************************");
        System.out.println("   欢迎"+a1[a].getAccountname()+"使用中国工商银行自助柜员系统");
        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("****************************************************************");
        System.out.println("                      请输入:");
        Scanner sc = new Scanner (System.in);
        int temp = sc.nextInt();
              switch(temp)
                 {
                case 1:a1[a].setOperatetype(1);writefile();deposit(a);break;
                 case 2:a1[a].setOperatetype(2);writefile();draw(a);break;
                 case 3:a1[a].setOperatetype(3);writefile();zhuan(a);break;
                 case 4:a1[a].setOperatetype(4);writefile();xiugai(a);break;
                 case 5:a1[a].setOperatetype(5);writefile();yu(a);break;
                 default:serviceAll(a);break;
                 }   
}
public void deposit(int a)throws IOException{
    System.out.println("***************************************************************");
    System.out.println("   欢迎"+a1[a].getAccountname()+"使用中国工商银行自助柜员系统");
    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("                 请输入存款金额;");
    Scanner sc = new Scanner (System.in);
    if(sc.hasNext("q"))
     login();
    else{
     int JinE = sc.nextInt();//记录金额
                  if(JinE<=0)
                  {
                      System.out.println(" 输入金额有误");
                      deposit(a);
                  }
                  else
                  {
                      a1[a].setAmount(a1[a].getAmount()+JinE);
                      a1[a].setAccountbalance(a1[a].getAccountbalance()+JinE);
                      //-----------------------[数据载入文档]
                      System.out.println("***************************************************************");
                      System.out.println("   欢迎"+a1[a].getAccountname()+"使用中国工商银行自助柜员系统");
                      System.out.println("****************************************************************");
                      System.out.println("                当前账户存款操作成功。");
                      System.out.println("             当前账户余额为:"+a1[a].getAccountbalance()+"元");
                      Scanner scs = new Scanner (new FileReader(List));
                      PrintWriter pws = new PrintWriter (new FileWriter("files/LinShi"));
                      while(!scs.hasNext("ENDOFTHISFILE"))//将 List 文件里的数据临时储存在 LinShi 文件下
                      {
                          pws.println(scs.nextLine());
                      }
                      pws.println(scs.nextLine());
                      pws.close();
                      Scanner scp = new Scanner (new FileReader("files/LinShi"));
                      PrintWriter pw = new PrintWriter (new FileWriter(List));
                      pw.print(a1[a].getAccountID());
                      pw.print(" ");
                      pw.print(Today);
                      a1[a].setOperatedate(Today);
                      pw.print(" ");
                      pw.print("SaveMoney");
                      pw.print(" ");
                      pw.println(JinE);
                      while(!scp.hasNext("ENDOFTHISFILE"))
                      {
                          pw.println(scp.nextLine());
                      }
                      pw.println(scp.nextLine());
                     pw.close();
                      writefile();
                     //----------------------------------------
                      serviceAll(a);
                  }
              }       
     
     
    }
public void draw(int a)throws IOException{
  System.out.println("***************************************************************");
  System.out.println("欢迎"+a1[a].getAccountname()+"使用中国工商银行自助柜员系统:");
  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("***************************************************************:");
  Scanner sc = new Scanner (System.in);
  int q = sc.nextInt();
  switch(q){
           case 1:
           {
               if(a1[a].getAccountbalance()<100)
               {
                   System.out.println("账户余额不足");
                   deposit(a);
               }
               else
               {
                   a1[a].setAmount(a1[a].getAmount()+100);
                   a1[a].setAccountbalance(a1[a].getAccountbalance()-100);
                   System.out.println("***************************************************************");
                   System.out.println("   欢迎"+a1[a].getAccountname()+"使用中国工商银行自助柜员系统");
                   System.out.println("****************************************************************");
                   System.out.println("             当前账户取款操作100元成功。");
                   System.out.println("             当前账户余额为:"+a1[a].getAccountbalance()+"元");
                  //----------------------------------------------------<以下为文件更新阶段
                   Scanner scs = new Scanner (new FileReader(List));
                   PrintWriter pws = new PrintWriter (new FileWriter("files/LinShi"));
                   while(!scs.hasNext("ENDOFTHISFILE"))//将 List 文件里的数据临时储存在 LinShi 文件下
                   {
                       pws.println(scs.nextLine());
                   }
                   pws.println(scs.nextLine());
                   pws.close();
                   Scanner scp = new Scanner (new FileReader("files/LinShi"));
                   PrintWriter pw = new PrintWriter (new FileWriter(List));
                   pw.print(a1[a].getAccountID());
                   pw.print(" ");
                   pw.print(Today);
                   a1[a].setOperatedate(Today);
                   pw.print(" ");
                   pw.print("GetMoney");
                   pw.print(" ");
                   pw.println(100);
                   while(!scp.hasNext("ENDOFTHISFILE"))
                   {
                       pw.println(scp.nextLine());
                   }
                  pw.println(scp.nextLine());
                  pw.close();
                  writefile();
                  serviceAll(a);
               }
               break;
          }
           case 2:
           {
               if(a1[a].getAccountbalance()<500)
               {
                   System.out.println("账户余额不足");
                   deposit(a);
              }
               else
               {
                   a1[a].setAmount(a1[a].getAmount()+500);
                   a1[a].setAccountbalance(a1[a].getAccountbalance()-500);
                   System.out.println("***************************************************************");
                   System.out.println("   欢迎"+a1[a].getAccountname()+"使用中国工商银行自助柜员系统");
                   System.out.println("****************************************************************");
                   System.out.println("             当前账户取款操作500元成功。");
                   System.out.println("             当前账户余额为:"+a1[a].getAccountbalance()+"元");
                   //----------------------------------------------------<以下为文件更新阶段
                   Scanner scs = new Scanner (new FileReader(List));
                   PrintWriter pws = new PrintWriter (new FileWriter("files/LinShi"));
                   while(!scs.hasNext("ENDOFTHISFILE"))//将 List 文件里的数据临时储存在 LinShi 文件下
                   {
                       pws.println(scs.nextLine());
                   }
                   pws.println(scs.nextLine());
                   pws.close();
                   Scanner scp = new Scanner (new FileReader("files/LinShi"));
                   PrintWriter pw = new PrintWriter (new FileWriter(List));
                   pw.print(a1[a].getAccountID());
                   pw.print(" ");
                   pw.print(Today);
                   a1[a].setOperatedate(Today);
                   pw.print(" ");
                   pw.print("GetMoney");
                   pw.print(" ");
                   pw.println(500);
                   while(!scp.hasNext("ENDOFTHISFILE"))
                   {
                       pw.println(scp.nextLine());
                   }
                   pw.println(scp.nextLine());
                   pw.close();
                   writefile();
                   //-----------------------------------
                   serviceAll(a);
               }
               break;
           }
           case 3:
           {
               if(a1[a].getAccountbalance()<1000)
               {
                   System.out.println("账户余额不足");
                   draw(a);
              }
               else
               {
                   a1[a].setAmount(a1[a].getAmount()+1000);
                   a1[a].setAccountbalance(a1[a].getAccountbalance()-1000);
                   System.out.println("***************************************************************");
                   System.out.println("   欢迎"+a1[a].getAccountname()+"使用中国工商银行自助柜员系统");
                   System.out.println("****************************************************************");
                   System.out.println("             当前账户取款操作1000元成功。");
                   System.out.println("             当前账户余额为:"+a1[a].getAccountbalance()+"元");
                   Scanner scs = new Scanner (new FileReader(List));
                   PrintWriter pws = new PrintWriter (new FileWriter("files/LinShi"));
                   while(!scs.hasNext("ENDOFTHISFILE"))
                   {
                       pws.println(scs.nextLine());
                   }
                   pws.println(scs.nextLine());
                   pws.close();
                   Scanner scp = new Scanner (new FileReader("files/LinShi"));
                   PrintWriter pw = new PrintWriter (new FileWriter(List));
                   pw.print(a1[a].getAccountID());
                   pw.print(" ");
                   pw.print("GetMoney");
                   pw.print(" ");
                   pw.println(1000);
                   while(!scp.hasNext("ENDOFTHISFILE"))
                   {
                       pw.println(scp.nextLine());
                   }
                   pw.println(scp.nextLine());
                  pw.close();
                   //-----------------------------------
                   serviceAll(a);
               }
               break;
           }
           case 4:
           {
               if(a1[a].getAccountbalance()<1500)
               {
                   System.out.println("账户余额不足");
                   draw(a);
               }
               else
               {
                   a1[a].setAmount(a1[a].getAmount()+1500);
                   a1[a].setAccountbalance(a1[a].getAccountbalance()-1500);
                   System.out.println("***************************************************************");
                   System.out.println("   欢迎"+a1[a].getAccountname()+"使用中国工商银行自助柜员系统");
                  System.out.println("****************************************************************");
                   System.out.println("             当前账户取款操作1500元成功。");
                   System.out.println("             当前账户余额为:"+a1[a].getAccountbalance()+"元");
                   //----------------------------------------------------<以下为文件更新阶段
                   Scanner scs = new Scanner (new FileReader(List));
                   PrintWriter pws = new PrintWriter (new FileWriter("files/LinShi"));
                 while(!scs.hasNext("ENDOFTHISFILE"))//将 List 文件里的数据临时储存在 LinShi 文件下
                   {
                       pws.println(scs.nextLine());
                   }
                   pws.println(scs.nextLine());
                   pws.close();
                   Scanner scp = new Scanner (new FileReader("files/LinShi"));
                   PrintWriter pw = new PrintWriter (new FileWriter(List));
                  pw.print(a1[a].getAccountID());
                   pw.print(" ");
                   pw.print(Today);
                   a1[a].setOperatedate(Today);
                  pw.print(" ");
                  writefile();
                   pw.print("GetMoney");
                   pw.print(" ");
                   pw.println(1500);
                   while(!scp.hasNext("ENDOFTHISFILE"))
                   {
                       pw.println(scp.nextLine());
                   }
                   pw.println(scp.nextLine());
                   pw.close();
                   //-----------------------------------
                   serviceAll(a);
               }
               break;
           }
           case 5:
           {
               if(a1[a].getAccountbalance()<2000)
               {
                   System.out.println("账户余额不足");
                   draw(a);
               }
               else
               {
                   a1[a].setAmount(a1[a].getAmount()+2000);
                   a1[a].setAccountbalance(a1[a].getAccountbalance()-2000);
                   System.out.println("***************************************************************");
                   System.out.println("   欢迎"+a1[a].getAccountname()+"使用中国工商银行自助柜员系统");
                   System.out.println("****************************************************************");
                   System.out.println("             当前账户取款操作2000元成功。");
                   System.out.println("             当前账户余额为:"+a1[a].getAccountbalance()+"元");
                   //----------------------------------------------------<以下为文件更新阶段
                   Scanner scs = new Scanner (new FileReader(List));
                   PrintWriter pws = new PrintWriter (new FileWriter("files/LinShi"));
                   while(!scs.hasNext("ENDOFTHISFILE"))//将 List 文件里的数据临时储存在 LinShi 文件下
                   {
                       pws.println(scs.nextLine());
                   }
                   pws.println(scs.nextLine());
                   pws.close();
                   Scanner scp = new Scanner (new FileReader("files/LinShi"));
                   PrintWriter pw = new PrintWriter (new FileWriter(List));
                   pw.print(a1[a].getAccountID());
                   pw.print(" ");
                   pw.print(Today);
                   a1[a].setOperatedate(Today);
                   pw.print(" ");
                   writefile();
                   pw.print("GetMoney");
                   pw.print(" ");
                   pw.println(2000);
                   while(!scp.hasNext("ENDOFTHISFILE"))
                   {
                       pw.println(scp.nextLine());
                  }
                   pw.println(scp.nextLine());
                   pw.close();
                   //-----------------------------------
                   serviceAll(a);
               }
               break;
           }
           case 6:
           {
               if(a1[a].getAccountbalance()<5000)
               {
                   System.out.println("账户余额不足");
                   draw(a);
               }
               else
               {
                   a1[a].setAmount(a1[a].getAmount()+5000);
                   a1[a].setAccountbalance(a1[a].getAccountbalance()-5000);
                   System.out.println("***************************************************************");
                   System.out.println("   欢迎"+a1[a].getAccountname()+"使用中国工商银行自助柜员系统");
                   System.out.println("****************************************************************");
                   System.out.println("             当前账户取款操作5000元成功。");
                   System.out.println("             当前账户余额为:"+a1[a].getAccountbalance()+"元");
                   //----------------------------------------------------<以下为文件更新阶段
                   Scanner scs = new Scanner (new FileReader(List));
                   PrintWriter pws = new PrintWriter (new FileWriter("files/LinShi"));
                   while(!scs.hasNext("ENDOFTHISFILE"))//将 List 文件里的数据临时储存在 LinShi 文件下
                   {
                       pws.println(scs.nextLine());
                   }
                   pws.println(scs.nextLine());
                   pws.close();
                   Scanner scp = new Scanner (new FileReader("files/LinShi"));
                   PrintWriter pw = new PrintWriter (new FileWriter(List));
                   pw.print(a1[a].getAccountID());
                   pw.print(" ");
                   pw.print(Today);
                   a1[a].setOperatedate(Today);
                   pw.print(" ");
                   writefile();
                   pw.print("GetMoney");
                   pw.print(" ");
                   pw.println(5000);
                   while(!scp.hasNext("ENDOFTHISFILE"))
                   {
                       pw.println(scp.nextLine());
                   }
                   pw.println(scp.nextLine());
                   pw.close();
                   //-----------------------------------
                   serviceAll(a);
               }
               break;
           }
           case 7:
           {
               System.out.println("***************************************************************");
               System.out.println("   欢迎"+a1[a].getAccountname()+"使用中国工商银行自助柜员系统");
               System.out.println("****************************************************************");
               System.out.println("                请输入取款金额:");
               int num = sc.nextInt();
             if(a1[a].getAccountbalance()<num)
               {
                   System.out.println("账户余额不足");
                   draw(a);
               }
              else
               {
                   a1[a].setAmount(a1[a].getAmount()+num);
                   a1[a].setAccountbalance(a1[a].getAccountbalance()-num);
                   System.out.println("***************************************************************");
                   System.out.println("   欢迎"+a1[a].getAccountname()+"使用中国工商银行自助柜员系统");
                   System.out.println("****************************************************************");
                   System.out.println("             当前账户取款操作"+num+"元成功。");
                   System.out.println("             当前账户余额为:"+a1[a].getAccountbalance()+"元");
                   writefile();
                   //----------------------------------------------------<以下为文件更新阶段
                   Scanner scs = new Scanner (new FileReader(List));
                   PrintWriter pws = new PrintWriter (new FileWriter("files/LinShi"));
                   while(!scs.hasNext("ENDOFTHISFILE"))//将 List 文件里的数据临时储存在 LinShi 文件下
                   {
                       pws.println(scs.nextLine());
                   }
                  pws.println(scs.nextLine());
                  pws.close();
                  Scanner scp = new Scanner (new FileReader("files/LinShi"));
                   PrintWriter pw = new PrintWriter (new FileWriter(List));
                   pw.print(a1[a].getAccountID());
                   pw.print(" ");
                   pw.print(Today);
                   a1[a].setOperatedate(Today);
                   pw.print(" ");
                  writefile();
                   pw.print("GetMoney");
                   pw.print(" ");
                   pw.println(num);
                   while(!scp.hasNext("ENDOFTHISFILE"))
                   {
                       pw.println(scp.nextLine());
                   }
                   pw.println(scp.nextLine());
                   pw.close();
                   serviceAll(a);
               }
               break;
           }
           case 8:
           {
               login();
               break;
           }
           case 9:
           {
              serviceAll(a);
               break;
           }
           default:draw(a);break;
           }
       }
public void zhuan(int a)throws IOException{
  System.out.println("***************************************************************");
           System.out.println("   欢迎"+a1[a].getAccountname()+"使用中国工商银行自助柜员系统");
           System.out.println("***************************************************************");
           System.out.println("                     请输入转账账户;");
           Scanner sc = new Scanner (System.in);
           if(sc.hasNext("q"))
               login();
           String temp = sc.next();
           int tube = 5;//记录账户
           for(int i=0;i<5;i++){
               if(a1[i].getAccountID().compareTo(temp)==0)
               {
                   tube = i;
                   break;
               }
           }
           if(tube==5)
           {
               System.out.println(" #:该用户不存在");
               zhuan(a);
           }
           else
           {
               zhuan_half(a,tube);
           }
       }
public void zhuan_half(int a,int a_to)throws IOException {
           System.out.println("***************************************************************");
           System.out.println("   欢迎"+a1[a].getAccountname()+"使用中国工商银行自助柜员系统");
           System.out.println("***************************************************************");
           System.out.println("                   请输入转账金额;");
           Scanner sc = new Scanner (System.in);
           if(sc.hasNext("q"))
               login();
           int JinE= sc.nextInt();
           if(JinE>a1[a].getAccountbalance())
           {
               System.out.println("账户余额不足");
               zhuan_half(a,a_to);
           }
           else if(JinE<=0)
               zhuan_half(a,a_to);
           else
           {
               StringBuffer sxw = new StringBuffer(a1[a_to].getAccountname());
               sxw.deleteCharAt(0);
               System.out.println("***************************************************************");
               System.out.println("   欢迎"+a1[a].getAccountname()+"使用中国工商银行自助柜员系统");
               System.out.println("***************************************************************");
               System.out.println("          请确认是否向*"+sxw+"转账"+JinE+"元。");
               String makesure = sc.next();
               if(sc.hasNext("q"))
                   login();
               if(makesure.compareTo("Y")==0)
               {
                   a1[a].setAccountbalance(a1[a].getAccountbalance()-JinE);
                   a1[a].setAmount(a1[a].getAmount()+JinE);
                   a1[a_to].setAccountbalance(a1[a_to].getAccountbalance()+JinE);
                   a1[a_to].setAmount(a1[a_to].getAmount()+JinE);
                   System.out.println("***************************************************************");
                   System.out.println("   欢迎"+a1[a].getAccountname()+"使用中国工商银行自助柜员系统");
                   System.out.println("***************************************************************");
                   System.out.println("          当前账户向*"+sxw+"转账"+JinE+"元。");
                   System.out.println("          当前账户余额为:"+a1[a].getAccountbalance()+"元");
               }
               //----------------------------------------------------<以下为文件更新阶段
               Scanner scs = new Scanner (new FileReader(List));
               PrintWriter pws = new PrintWriter (new FileWriter("files/LinShi"));
               while(!scs.hasNext("ENDOFTHISFILE"))//将 List 文件里的数据临时储存在 LinShi 文件下
               {
                   pws.println(scs.nextLine());
               }
               pws.println(scs.nextLine());
               pws.close();
               Scanner scp = new Scanner (new FileReader("files/LinShi"));
               PrintWriter pw = new PrintWriter (new FileWriter(List));
               pw.print(a1[a].getAccountID());
               pw.print(" ");
               pw.print(Today);
               a1[a].setOperatedate(Today);
               pw.print(" ");
               writefile();
               pw.print("RemoveMoney");
               pw.print(" ");
               pw.println(JinE);
               while(!scp.hasNext("ENDOFTHISFILE"))
               {
                   pw.println(scp.nextLine());
               }
               pw.println(scp.nextLine());
               pw.close();
               //-----------------------------------
               serviceAll(a);
           }
}
public void xiugai(int a)throws IOException{
    System.out.println("***************************************************************");
         System.out.println("   欢迎"+a1[a].getAccountname()+"使用中国工商银行自助柜员系统");
         System.out.println("***************************************************************");
         String str1,str2;
         System.out.println("                  请输入当前密码:  ");
         Scanner sc = new Scanner (System.in);
         str1 = sc.next();
         if(sc.hasNext("q"))
             login();
         if(a1[a].getAccountpassword().compareTo(str1)==0)
         {
             System.out.println("                  请输入修改密码:");
             str1 = sc.next();
             if(sc.hasNext("q"))
                 login();
             System.out.println("                  请输入确认密码:");
             str2 = sc.next();
             if(sc.hasNext("q"))
                 login();
             if(str1.compareTo(str2)==0)
             {
                 a1[a].setAccountpassword(str1);
                 writefile();
                 System.out.println("***************************************************************");
                 System.out.println("   欢迎"+a1[a].getAccountname()+"使用中国工商银行自助柜员系统");
                 System.out.println("***************************************************************");
                 System.out.println("           当前账户密码修改成功");
                 //----------------------------------------------------<以下为文件更新阶段
                 Scanner scs = new Scanner (new FileReader(List));
                 PrintWriter pws = new PrintWriter (new FileWriter("files/LinShi"));
                 while(!scs.hasNext("ENDOFTHISFILE"))//将 List 文件里的数据临时储存在 LinShi 文件下
                 {
                     pws.println(scs.nextLine());
                 }
                 pws.println(scs.nextLine());
                 pws.close();
                 Scanner scp = new Scanner (new FileReader("files/LinShi"));
                 PrintWriter pw = new PrintWriter (new FileWriter(List));
                 pw.print(a1[a].getAccountID());
                 pw.print(" ");
                 pw.print(Today);
                 a1[a].setOperatedate(Today);
                 pw.print(" ");
                 writefile();
                 pw.print("Changeaword");
                 pw.print(" ");
                 pw.println("**********");
                 while(!scp.hasNext("ENDOFTHISFILE"))
                 {
                     pw.println(scp.nextLine());
                 }
                 pw.println(scp.nextLine());
                 pw.close();
                 //-----------------------------------
                 serviceAll(a);
             }
             else
             {
                 System.out.println("          修改密码与确认密码不一致");
                 xiugai(a);
             }
         }
         else
         {
             System.out.println("         当前密码录入错误");
             xiugai(a);
         }
 
 
 
}  
public void yu(int a)throws IOException{
   System.out.println("***************************************************************");
            System.out.println("   欢迎"+a1[a].getAccountname()+"使用中国工商银行自助柜员系统");
            System.out.println("***************************************************************");
            System.out.println("                  当前账户余额为:"+a1[a].getAccountbalance()+"元");
            System.out.println("                    账户清单信息为:");
            int sx = 1;
            Scanner sl = new Scanner (new File(List));
            while(true)
            {
                String str3 = sl.next();//账户
                if(str3.compareTo("ENDOFTHISFILE")==0)
                    break;
                String str1 = sl.next();//日期
                String str2 = sl.next();//操作类型
                String dateofthis = sl.next();//操作金额
                if(a1[a].getAccountID().compareTo(str3)==0)
                {
                    System.out.println(sx+"、"+str1+"  "+str2+"   "+dateofthis);
                    sx++;
                }
            }
            serviceAll(a);
 

public AccountManager() throws FileNotFoundException{
         for(int i=0;i<5;i++)
             a1[i] = new Account();
         readfile();
     }
public void writefile() throws IOException{
         FileWriter fr = new FileWriter(Infor);
         BufferedWriter bw = new BufferedWriter(fr);
         PrintWriter fl = new PrintWriter(bw);
         for(int i =0;i<5;i++)
         {
             fl.print(a1[i].getAccountID());
             fl.print(‘ ‘);
             fl.print(a1[i].getAccountname());
             fl.print(‘ ‘);
             fl.print(a1[i].getOperatedate());
             fl.print(‘ ‘);
             fl.print(a1[i].getOperatetype());
             fl.print(‘ ‘);
             fl.print(a1[i].getAccountpassword());
             fl.print(‘ ‘);
             fl.print(a1[i].getAccountbalance());
             fl.print(‘ ‘);
             fl.print(a1[i].getAmount());
             fl.print(" ");
         }
         fl.close();
     }
public void readfile() throws FileNotFoundException{
         Scanner fl = new Scanner(new File(Infor));
         for(int i=0;i<5;i++)
             a1[i]=new Account(fl.next(),fl.next(),fl.next(),fl.nextInt(),fl.next(),fl.nextInt(),fl.nextInt());
     }

}
   
主函数
package ATM模拟;
import java.io.IOException;
public class ATM {
public static void main(String[] args)throws IOException{
    AccountManager accou = new AccountManager();
         accou.login(); 
 }
}
 














































































































































































































































































































































































































































































































































































































































































































































































































































































以上是关于ATM的主要内容,如果未能解决你的问题,请参考以下文章

ATM java

网络接口ATM协议

模拟ATM(C语言)

ATM:模拟实现一个ATM + 购物商城程序

python基础之ATM-1

Atmosic推出ATM33新品,全新的ATM33系列性能大升级