java考试

package ATM;
import java.util.Scanner;
/**
 * 操作学生数据
 * 
 * @author Administrator
 *
 */ 
public class AccountManager { 
  static Scanner sc = new Scanner(System.in);
  
    
  
     /**
      * 主菜单
      */ 
     public static void menu()
     {
     System.out.println("*********************************");
     System.out.println("欢迎使用中国工商银行自助系统");
     System.out.println("*********************************");
     System.out.println("请输入您的帐号:");
     System.out.println("*********************************");
     int flag=1;
     while(flag==1)
     {
     String num= sc.next();
     if(num.length()!=8)
     {System.out.println("输入错误,请重新输入");
      flag=1;
     }
     else flag=0;
     }
     if(flag==0)
      
      {System.out.println("*********************************");
      System.out.println("欢迎使用中国工商银行自助系统");
      System.out.println("*********************************");
      System.out.println("请输入您的密码:");
      System.out.println("*********************************");
      }
     int index=1;
      for(int i=0;i<3;i++)
      {
      String word=sc.next();
      if(word.length()!=6)
      {System.out.println("输入错误,请重新输入");
      index=0;
      }
      else break;
      }
      if(index==0)
       System.out.println("输入密码三次错误,卡已被没收");
      }
     
      }
 
 
package ATM;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

public class read
{
 
  
  
   
 
     public static ArrayList<String> accountID= new ArrayList<String>();
  public static ArrayList<String> accountname = new ArrayList<String>();
  public static ArrayList<String> accountpssword= new ArrayList<String>(); 
     public static ArrayList<Integer> accountbalance = new ArrayList<Integer>();
     public static File file = new File("D:\accountinformation.txt");
 
     static { 
  
         ArrayList<String> temp = new ArrayList<String>(); 
         try { 
             BufferedReader br = new BufferedReader(new FileReader(file)); 
  
             String read = br.readLine(); 
             while (read != null) { 
                 temp.add(read); 
                 read = br.readLine(); 
             } 
             br.close(); 
         } catch (FileNotFoundException e) { 
             // TODO Auto-generated catch block 
             e.printStackTrace(); 
         } catch (IOException e) { 
             // TODO Auto-generated catch block 
             e.printStackTrace(); 
         } 
  
         for (int i = 0; i < temp.size(); i++) { 
             String[] sTemp = ((String) temp.get(i)).split(","); 
    accountID.add(sTemp[0]); 
             accountname.add(sTemp[1]); 
             accountpssword.add(sTemp[2]);
       
             accountbalance.add(Integer.parseInt(sTemp[3])); 
         } 
  
     } 
  
 } 
 
 
 
 
package ATM;

import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.IOException;
import java.util.ArrayList;

public class read2
{
 
  
  
   
 
     public static ArrayList<String> accountID= new ArrayList<String>();
  public static ArrayList<String> accountname = new ArrayList<String>();
  public static ArrayList<String> operatedate= new ArrayList<String>(); 
     public static ArrayList<Integer> operatetype = new ArrayList<Integer>();
     public static ArrayList<Integer> amount = new ArrayList<Integer>();
     public static File file = new File("D:\accountlist.txt");
 
     static { 
  
         ArrayList<String> tem = new ArrayList<String>(); 
         try { 
             BufferedReader cr = new BufferedReader(new FileReader(file)); 
  
             String read = cr.readLine(); 
             while (read != null) { 
                 tem.add(read); 
                 read = cr.readLine(); 
             } 
             cr.close(); 
         } catch (FileNotFoundException e) { 
             // TODO Auto-generated catch block 
             e.printStackTrace(); 
         } catch (IOException e) { 
             // TODO Auto-generated catch block 
             e.printStackTrace(); 
         } 
  
         for (int i = 0; i < tem.size(); i++) { 
             String[] sTemp = ((String) tem.get(i)).split(","); 
    accountID.add(sTemp[0]); 
             accountname.add(sTemp[1]); 
             operatedate.add(sTemp[2]);
       
             operatetype.add(Integer.parseInt(sTemp[3])); 
             amount.add(Integer.parseInt(sTemp[4]));
         } 
  
     } 
  
 } 
 
 
package ATM;
public class test {
 public static void main(String[] args)
 {
  AccountManager.menu();
  // TODO Auto-generated method stub
 }
}
原文地址:https://www.cnblogs.com/Evak/p/9687920.html