Supplement the first exam

Source: Internet
Author: User

The first exam of the one has not been completed, is getlist (), today there is no time to solve, not many BB, on the code.

Package Java first week learning 2;import java.io.filereader;import Java.io.filewriter;import Java.io.printwriter;import Java.util.arraylist;import Java.util.linkedlist;import Java.util.list;import Java.util.scanner;public class Accountmanager {public static void main (string[] args) {linkedlist<account> acc=new linkedlist<account> ();          Scanner shuru=new Scanner (system.in);          GetInformation (ACC);     int flag;     System.out.println (Acc.get (0). Getaccountid ());    System.out.println (Acc.size ()); Panding (ACC);} Decision account public static void Panding (Linkedlist<account> acc) {Scanner Shuru = new Scanner (system.in); int flag = 0;int j=0; String zhanghao;while (flag = = 0) {System.out.println ("************************************************************ ***"); System.out.println ("Welcome to ICBC Automatic Teller system"); System.out.println ("****************************************************************"); System.out.println ("Please enter your account number:"); System.out.println (); System.out.priNtln ("****************************************************************"); Zhanghao = Shuru.next ();// System.out.println (Zhanghao); if (Zhanghao.length ()! = 8) {System.out.println ("The card is not a ICBC card");} else {//system.out.println (Zhanghao); for (int i = 0; i < acc.size (); i++) {if (Zhanghao.equals (Acc.get (i). Getaccountid ())) {flag = 1;j=i;} System.out.println (j);} {if (flag = = 0) {System.out.println ("The account does not exist");} else {Shurumima (acc,j);}}}} The decision password A is a fixed account public static void Shurumima (Linkedlist<account> acc,int a) {int i=0;while (i<3) { System.out.println ("***************************************************************"); System.out.printf ("Welcome"); System.out.print (Acc.get (a). Getaccountname ()); System.out.printf ("Using ICBC self-service teller system"); System.out.println ("****************************************************************"); System.out.println ("Please enter your password:"); System.out.println (); System.out.println ("****************************************************************"); String Mima; Scanner Shuru = new Scanner (system.in); Mima=shuru.next (); if (Mima.equals (Acc.get (a). Getaccontpassword ())) {i=5;} else {System.out.println ("Password entry error"); i=i+1;}} if (i==5) {Gongneng (acc,a);} else {System.out.println ("This account three times entered the password error, the card has been confiscated by the system, please contact ICBC timely processing");}} Main interface public static void Gongneng (Linkedlist<account> acc, int. a) {String q= "q"; while (Q.equals ("Q")) { System.out.println ("***************************************************************"); System.out.printf ("Welcome"); System.out.printf (Acc.get (a). Getaccountname ()); System.out.println ("Using ICBC self-service teller system"); System.out.println ("****************************************************************"); System.out.println ("1. Deposit"); System.out.println ("2. Withdrawal"); System.out.println ("3. Transfer remittance"); System.out.println ("4. Change Password"); System.out.println ("5. Enquiry balance"); System.out.println (); System.out.println ("****************************************************************"); int key = 0; Scanner Shuru = new Scanner (system.in); key = Shuru.nextint (); Acc.get (a). Setoperatetype (key), switch (key) {case 1:cunkuan (acc,a); Q=shuru.next (); break;case 2:qukuan (acc,a); q= Shuru.next (); break;case 3:zhuanzhang (Acc,a); Q=shuru.next (); break;case 4:xiugai (Acc,a); Q=shuru.next (); Break;case 5 : Chaxun (Acc,a); Q=shuru.next (); break;}}} public static void Chaxun (linkedlist<account> acc, int a) {System.out.println ("*************;****************** ********************************"); System.out.printf ("Welcome"); System.out.printf (Acc.get (a). Getaccountname ()); System.out.printf ("Using ICBC self-service teller system"); System.out.println ("****************************************************************"); System.out.printf ("Current account balance is:"); System.out.println (Acc.get (a). Getaccountbalance ()); System.out.println ("Account list information is:"); Account Q1=acc.get (a); GetList (A, ACC); Q1.getamount (); System.out.println ("****************************************************************");} public static void Cunkuan (Linkedlist<account> acc,int a) {int qian;int i=0;while (i==0) {System.out.println ("********************************************************* ******"); System.out.printf ("Welcome"); System.out.printf (Acc.get (a). Getaccountname ()); System.out.printf ("Using ICBC self-service teller system"); System.out.println ("****************************************************************"); System.out.println ("Please enter Deposit Amount:"); System.out.println (); System.out.println ("****************************************************************");    Scanner Shuru = new Scanner (system.in);    Qian=shuru.nextint ();    if (qian>0) {int yue=0;    Yue=acc.get (a). Getaccountbalance () +qian;    Acc.get (a). Setaccountbalance (Yue);    I=1;    Acc.get (a). Setamount (Qian);    Acc.get (a). Setoperatedate ("");    SetInformation (ACC); Setlist (A, ACC); System.out.println ("***************************************************************"); System.out.printf ("Welcome"); System.out.printf (Acc.get (a). Getaccountname ()); System.out.printf ("Using ICBC self-service teller system"); SYstem.out.println ("****************************************************************"); System.out.println ("The current account deposit operation is successful. "); System.out.printf ("Current account balance is:"); System.out.println (Yue); System.out.println ();    System.out.println ("****************************************************************");    } else {System.out.println ("Incorrect input amount"); }}}public static void Xiugai (linkedlist<account> acc, int a) {String mima= ""; String mima1= ""; String mima2= ""; System.out.println ("***************************************************************"); System.out.printf ("Welcome"); System.out.printf (Acc.get (a). Getaccountname ()); System.out.printf ("Using ICBC self-service teller system"); System.out.println ("****************************************************************"); System.out.println ("Please enter your current password::"); System.out.println ("****************************************************************"); Scanner Shuru = new Scanner (system.in); Mima=shuru.next (); if (Mima.equals (Acc.get (a). Getaccontpassword () {System.out.println ("Please Enter Change Password:"); Mima1=shuru.next (); System.out.println ("Please Enter Change Password:"); Mima2=shuru.next (); if (Mima1.equals (MIMA2)) {Acc.get (a). Setaccontpassword (MIMA1)           ;           Acc.get (a). Setoperatedate ("");           SetInformation (ACC);       Setlist (A, ACC); System.out.println ("***************************************************************"); System.out.printf ("Welcome"); System.out.printf (Acc.get (a). Getaccountname ()); System.out.printf ("Using ICBC self-service teller system"); System.out.println ("****************************************************************"); System.out.println ("Current Account password modified successfully"); System.out.println ("****************************************************************");} ELSE{SYSTEM.OUT.PRINTLN ("Change Password and Confirm password inconsistent");}} ELSE{SYSTEM.OUT.PRINTLN ("Current Password entry error");}} Transfer operation public static void Zhuanzhang (linkedlist<account> acc, int a) {int qian = 0; String Zhanghao = ""; int j = 0;int flag = 0; System.out.println ("***************************************************************"); System.out.printf ("Welcome"); System.out.printf (Acc.get (a). Getaccountname ()); System.out.printf ("Using ICBC self-service teller system"); System.out.println ("****************************************************************"); System.out.println ("Please enter the transfer account:"); System.out.println ("****************************************************************"); Scanner Shuru = new Scanner (system.in); Zhanghao = Shuru.next (); for (int i = 0; i < acc.size (); i++) {if (zhanghao.equal S (Acc.get (i). Getaccountid ())) {j = I;flag = 1;}} if (flag = = 1) {System.out.println ("***************************************************************"); System.out.printf ("Welcome"); System.out.printf (Acc.get (a). Getaccountname ()); System.out.printf ("Using ICBC self-service teller system"); System.out.println ("****************************************************************"); System.out.println ("Please enter the transfer amount:"); System.out.println ("****************************************************************"); qian = Shuru.nextint (); if (Qian < Acc.get (a). Getaccountbalance ()) {System.Out.println ("***************************************************************"); System.out.printf ("Welcome"); System.out.printf (Acc.get (a). Getaccountname ()); System.out.println ("Using ICBC self-service teller system"); System.out.println ("****************************************************************"); System.out.printf ("Please confirm whether to"); System.out.print (Acc.get (j). Getaccountname ()); System.out.print (Qian); System.out.println ("Yuan. "); System.out.println ("****************************************************************"); String F;f=shuru.next (), if (F.equals ("N")) {Acc.get (j). Setamount (Qian); Acc.get (a). Setaccountbalance (Acc.get (a). Getaccountbalance ()-qian); Acc.get (j). Setoperatedate (""); SetInformation (ACC); setlist (A, ACC); System.out.println ("***************************************************************"); System.out.printf ("Welcome"); System.out.printf (Acc.get (a). Getaccountname ()); System.out.println ("Using ICBC self-service teller system"); System.out.println ("****************************************************************"); System.out.printf ("Current account success to"); System.out.print (Acc.get (j). Getaccountname ()); System.out.print (Qian); System.out.println ("Yuan. "); System.out.println ("****************************************************************");}} else {System.out.println ("Insufficient account Balance");}} else {System.out.println ("The account does not exist");}} public static void Qukuan (linkedlist<account> acc, int a) {int key=0;int qian=0;int i=0; System.out.println ("***************************************************************"); System.out.printf ("Welcome"); System.out.printf (Acc.get (a). Getaccountname ()); System.out.printf ("Using ICBC self-service teller system"); System.out.println ("****************************************************************"); System.out.println ("1, 100 Yuan"); System.out.println ("2, 500 Yuan"); System.out.println ("3, 1000 Yuan"); System.out.println ("4, 1500 Yuan"); System.out.println ("5, 2000 Yuan"); System.out.println ("6, 5000 yuan;"); System.out.println ("7, other Amount"); System.out.println ("8, Return card"); System.out.println ("9, return");    Scanner Shuru = new Scanner (system.in); Key=shuru.neXtint (); switch (key) {Case 1:if (Acc.get (a). Getaccountbalance () >100) {Qian =100;acc.get (a). Setaccountbalance ( Acc.get (a). Getaccountbalance ()-qian); Acc.get (a). Setamount (Qian); I=1;} else {System.out.println ("Insufficient account Balance");} Break;case 2:if (Acc.get (a). Getaccountbalance () >500) {Qian =500;acc.get (a). Setaccountbalance (Acc.get (a). Getaccountbalance ()-qian); Acc.get (a). Setamount (Qian); I=1;} else {System.out.println ("Insufficient account Balance");} Break;case 3:if (Acc.get (a). Getaccountbalance () >1000) {Qian =1000;acc.get (a). Setaccountbalance (Acc.get (a). Getaccountbalance ()-qian); Acc.get (a). Setamount (Qian); I=1;} else {System.out.println ("Insufficient account Balance");} Break;case 4:if (Acc.get (a). Getaccountbalance () >1500) {Qian =1500;acc.get (a). Setaccountbalance (Acc.get (a). Getaccountbalance ()-qian); Acc.get (a). Setamount (Qian); I=1;} else {System.out.println ("Insufficient account Balance");} Break;case 5:if (Acc.get (a). Getaccountbalance () >2000) {Qian =2000;acc.get (a). Setaccountbalance (Acc.get (a). Getaccountbalance ()-qian); Acc.get (a). Setamount (Qian); I=1;} else {SYSTEM.OUT.PRINTLN ("Insufficient account Balance");} Break;case 6:if (Acc.get (a). Getaccountbalance () >5000) {Qian =5000;acc.get (a). Setaccountbalance (Acc.get (a). Getaccountbalance ()-qian); Acc.get (a). Setamount (Qian); I=1;} else {System.out.println ("Insufficient account Balance");} Break;case 7:system.out.println ("***************************************************************"); System.out.printf ("Welcome"); System.out.printf (Acc.get (a). Getaccountname ()); System.out.printf ("Using ICBC self-service teller system"); System.out.println ("****************************************************************"); System.out.println ("Please enter the withdrawal amount:");    System.out.println ("****************************************************************");    Qian=shuru.nextint ();     if (Acc.get (a). Getaccountbalance () >qian) {Acc.get (a). Setamount (Qian);     Acc.get (a). Setaccountbalance (Acc.get (a). Getaccountbalance ()-qian); I=1;}      else {System.out.println ("Insufficient account Balance");}  Break;case 8:gongneng (acc,a); break;case 9:panding (ACC); break;}  Acc.get (a). Setoperatedate (""); SetinformatiOn (ACC);  Setlist (A, ACC);  GetInformation (ACC); if (i==1) {System.out.println ("***************************************************************"); System.out.printf ("Welcome"); System.out.printf (Acc.get (a). Getaccountname ()); System.out.printf ("Using ICBC self-service teller system"); System.out.println ("****************************************************************"); System.out.printf ("Current account withdrawal operation"); System.out.print (Qian); SYSTEM.OUT.PRINTLN ("meta success.") "); System.out.printf ("Current account balance is:"); System.out.print (Acc.get (a). Getaccountbalance ()); System.out.println ("Yuan");  System.out.println ("****************************************************************"); }}public static String getList (int i,linkedlist<account> ACC)//Read pipelining {try{filereader fr=new filereader ("e:\\ new Folder (3) \\src\\java The first week of study 2\\accountlist "); Scanner r=new Scanner (FR); String Iid=acc.get (i). Getaccountid (); String Id=new string (); String S=new string (), while (R.hasnextline ()) {Id=r.next (), if (Iid.equals (ID)) {System.out.printf (ID); System.out.println (R.nextliNE ());}}    Fr.close (); R.close (); Return "";} catch (Exception e) {System.out.println ("file read failed"); return "";}} public static void setlist (int i,linkedlist<account> ACC)//write pipelining {try{account a=acc.get (i); FileWriter fw=new FileWriter ("e:\\ new Folder (3) \\src\\java first week learning 2\\accountlist", true); PrintWriter pw=new PrintWriter (FW);p W.println (A.getaccountid () + "+a.getaccountname () +" "+ a.getoperatedate () +" + A.getoperatetype () + "" +a.getamount ());p W.flush ();p w.close (); Fw.close ();} catch (Exception e) {System.out.println ("file write Failed");}} public static void GetInformation (Linkedlist<account> ACC)//Get information {try{filereader fr=new filereader ("e:\\ New Folder (3 ) \\src\\java first week study 2\\accountinformation "); Scanner r=new Scanner (FR); while (R.hasnext ()) {account a=new account (); A.setaccountid (R.next ()); A.setaccontpassword ( R.next ()); A.setaccountname (R.next ()); A.setaccountbalance (R.nextint ()); Acc.add (a); Fr.close (); R.close ();} catch (Exception e) {System.out.println ("file write Failed");}} public static void SetInformation (Linkedlist<account> ACC)//write information {try{int i=0; FileWriter fw=new FileWriter ("e:\\ new Folder (3) \\src\\java first week learning 2\\accountinformation"); PrintWriter pw=new PrintWriter (FW); for (I=0;i<acc.size (); i++) {pw.println (Acc.get (i). Getaccountid () + "" +acc.get ( i). Getaccontpassword () + "" + acc.get (i). Getaccountname () + "" +acc.get (i). Getaccountbalance ());} Pw.flush ();p w.close (); Fw.close ();} catch (Exception e) {System.out.println ("file write Failed");}}}

  

Supplement the first exam

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.