标签:pass oid stream ase his rate can ntp print
package hellopeace; // 信1905-2 20194199 刘佳琦 import java.util.Scanner; import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; class Account { String accountID; String accountname; String operatedate; int operatetype; String accountpassword; int accountbalance; int amount; public String getaccountID() { return accountID; } public void setaccountID(String accountID) { this.accountID = accountID; } public String getoperatedate() { return operatedate; } public void setoperatedate(String operatedate) { this.operatedate = operatedate; } public String getaccountname() { return accountname; } public void setaccountname(String accountname) { this.accountname = accountname; } 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 getamount() { return amount; } public void setamount(int amount) { this.amount = amount; } public int getaccountbalance() { return accountbalance; } public void setaccountbalance(int accountbalance) { this.accountbalance = accountbalance; } Account(String accountID,String accountname,String operatedate,int operatetype,String accountpassword,int amount,int accountbalance) { this.accountID = accountID; this.operatedate = operatedate; this.operatetype = operatetype; this.accountpassword = accountpassword; this.amount = amount; this.accountname = accountname; this.accountbalance=accountbalance; } } public class rr { static int sum=0; static Scanner input = null; static Account[] accountinformation = new Account[1000]; public static String coder() { //输入账号 input = new Scanner(System.in); String accountID; int k; int p=0; System.out.println("*************************************************************** \n" + " 欢迎使用中国工商银行自动柜员系统\n" + "**************************************************************** \n" + " 请输入您的账号\n"+ "**************************************************************** \n"); accountID=input.next(); if (accountID.length()!=8) { System.out.print("该卡不是工行卡\n"); } for(k=0;k<1000;k++) { if( accountinformation[k].accountID.equals(accountID)) { p=1; } } return accountID; } public static int systemMenu() { input = new Scanner(System.in); System.out.println("***************************************************************\n" +"欢迎"+accountinformation[sum].accountname+"使用中国工商银行自助柜员系统\n" +"****************************************************************\n" +"1、存款;\n " +"2、取款;\n" +"3、转账汇款;\n " +"4、修改密码;\n" +"5、查询余额;\n" +"**************************************************************** "); int ch; System.out.println("请选择:"); ch = input.nextInt(); return ch; } public static int passer(String accountID) { //输入账号 input = new Scanner(System.in); String accountpassword; int k; int p=0; for(k=0;!(accountinformation[k].accountID.equals(accountID));k++){} System.out.println("*************************************************************** \n" + " 欢迎使用中国工商银行自动柜员系统\n" + "**************************************************************** \n" + " 请输入您的密码\n"+ "**************************************************************** \n"); accountpassword=input.next(); if(accountinformation[k].accountpassword.equals(accountpassword)) {p=1;} sum=k; return p; } public static void Addaccount(String accountID,String accountname,String accountpassword,int accountbalance){ int k; for(k=0;k<sum;k++) { if( accountinformation[k].accountID.equals(accountID) ) { System.out.println("账户重复"); return; } } accountinformation[sum] = new Account(accountID,accountname,"unknow",0,accountpassword,0,accountbalance); sum++; } public static void main(String[] args) { File ptr=new File("C:\\Users\\14997\\Desktop\\","accountinformation.txt"); File pan=new File(ptr.getParent()); input=new Scanner(System.in); String though; int pro,clone,cash; int check=0; int k1; int ac; String accountID; String accountname; String operatedate; int operatetype; String accountpassword; int amount; int accountbalance; int choice; System.out.println("现在是初始创建五名用户信息(请依照用户账号、用户名、用户密码、用户余额输入):"); for(k1=0;k1<5;k1++) { accountID = input.next(); accountname = input.next(); accountpassword= input.next(); accountbalance= input.nextInt(); rr.Addaccount(accountID,accountname,accountpassword,accountbalance); } sum=5; though=coder(); pro=passer(though); choice=systemMenu(); while(choice<=5&&choice>=1) { switch (choice) { case 1: System.out.print("***************************************************************\n" + "欢迎"+accountinformation[sum].accountname+"使用中国工商银行自助柜员系统\n" + "****************************************************************\n" + "请输入存款金额;\n" + " \n" + "****************************************************************"); ac=input.nextInt(); for(;ac<0;) { System.out.print("输入金额错误\n"); System.out.print("请重新输入金额\n"); ac=input.nextInt(); } accountinformation[sum].accountbalance=accountinformation[sum].accountbalance+ac; System.out.print("***************************************************************\r\n" + "欢迎"+accountinformation[sum].accountname+"使用中国工商银行自助柜员系统\r\n" + "****************************************************************\r\n" + "当前账户存款操作成功。\r\n" + "当前账户余额为:"+accountinformation[sum].accountbalance+"元\r\n" + "****************************************************************"); OutputStream output = System.out; byte[] byten=(accountinformation[sum].accountID+" 存入"+ac+"元\n").getBytes(); try { output.write(byten); } catch (IOException e) {} break; case 2: String we="y"; for(;we!="q";) { System.out.print("***************************************************************\r\n" + "欢迎"+accountinformation[sum].accountname+"使用中国工商银行自助柜员系统\r\n" + "****************************************************************当前账户每日可以支取2万元。\r\n" + "1、100元\r\n" + "2、500元\r\n" + "3、1000元\r\n" + "4、1500元\r\n" + "5、2000元\r\n" + "6、5000元;\r\n" + "7、其他金额\r\n" + "8、退卡\r\n" + "9、返回\r\n" + "****************************************************************"); clone=input.nextInt(); switch (clone) { case 1: accountinformation[sum].accountbalance=accountinformation[sum].accountbalance-100; if(accountinformation[sum].accountbalance<100) {System.out.println("余额不足,还有"+accountinformation[sum].accountbalance+"元");break;} OutputStream output2 = System.out; byte[] byten2=(accountinformation[sum].accountID+" 支出100元\n").getBytes(); try { output2.write(byten2); } catch (IOException e) {} break; case 2: accountinformation[sum].accountbalance=accountinformation[sum].accountbalance-500; if(accountinformation[sum].accountbalance<500) {System.out.println("余额不足,还有"+accountinformation[sum].accountbalance+"元");break;} OutputStream output3 = System.out; byte[] byten3=(accountinformation[sum].accountID+" 支出500元\n").getBytes(); try { output3.write(byten3); } catch (IOException e) {} break; case 3: accountinformation[sum].accountbalance=accountinformation[sum].accountbalance-1000; if(accountinformation[sum].accountbalance<1000) {System.out.println("余额不足,还有"+accountinformation[sum].accountbalance+"元");break;} OutputStream output4 = System.out; byte[] byten4=(accountinformation[sum].accountID+" 支出1000元\n").getBytes(); try { output4.write(byten4); } catch (IOException e) {} break; case 4: accountinformation[sum].accountbalance=accountinformation[sum].accountbalance-1500; if(accountinformation[sum].accountbalance<1500) {System.out.println("余额不足,还有"+accountinformation[sum].accountbalance+"元");break;} OutputStream output5 = System.out; byte[] byten5=(accountinformation[sum].accountID+" 支出1500元\n").getBytes(); try { output5.write(byten5); } catch (IOException e) {} break; case 5: accountinformation[sum].accountbalance=accountinformation[sum].accountbalance-2000; if(accountinformation[sum].accountbalance<2000) {System.out.println("余额不足,还有"+accountinformation[sum].accountbalance+"元");break;} OutputStream output6 = System.out; byte[] byten6=(accountinformation[sum].accountID+" 支出2000元\n").getBytes(); try { output6.write(byten6); } catch (IOException e) {} break; case 6: accountinformation[sum].accountbalance=accountinformation[sum].accountbalance-5000; if(accountinformation[sum].accountbalance<5000) {System.out.println("余额不足,还有"+accountinformation[sum].accountbalance+"元");break;} OutputStream output7 = System.out; byte[] byten7=(accountinformation[sum].accountID+" 支出5000元\n").getBytes(); try { output7.write(byten7); } catch (IOException e) {} break; case 7: int c; System.out.println("请输入取款金额"); c=input.nextInt(); for(;accountinformation[sum].accountbalance<c;) { System.out.println("余额不足,还有"+accountinformation[sum].accountbalance+"元,请重新输入"); } accountinformation[sum].accountbalance=accountinformation[sum].accountbalance-c; OutputStream output8 = System.out; byte[] byten8=(accountinformation[sum].accountID+" 支出"+c+"元\n").getBytes(); try { output8.write(byten8); } catch (IOException e) {} break; } System.out.println("请问要重新取款吗 按q退出"); we=input.next(); } break; case 3: String p; System.out.print("***************************************************************\n" + "欢迎"+accountinformation[sum].accountname+"使用中国工商银行自助柜员系统\n" + "****************************************************************\n" + "请输入转账账户;\n" + " \n" + "****************************************************************"); int k=1001; p=input.next(); for (;k==1001;) { for(k=0;accountinformation[k].accountID.equals(p);k++){} if(k==1001) {System.out.print("账户不存在,请重新输入");} p=input.next(); } int c; System.out.println("请输入转账金额"); c=input.nextInt(); for(;accountinformation[sum].accountbalance<c;) { System.out.println("余额不足,还有"+accountinformation[sum].accountbalance+"元,请重新输入"); } accountinformation[sum].accountbalance=accountinformation[sum].accountbalance-c; OutputStream output8 = System.out; byte[] byten8=(accountinformation[sum].accountID+" 支出"+c+"元\n"+accountinformation[k].accountID+" 存入"+c+"元\n").getBytes(); try { output8.write(byten8); } catch (IOException e) {} accountinformation[sum].accountbalance=accountinformation[sum].accountbalance+c; break; case 4: String self,self2="0",self3="1"; System.out.print("***************************************************************\n" + "欢迎"+accountinformation[sum].accountname+"使用中国工商银行自助柜员系统\r\n" + "****************************************************************\n" ); System.out.print("请输入当前密码:\n"); self=input.next(); for(;self!=accountinformation[sum].accountID;) {System.out.print("密码输入错误");self=input.next();} for(;self2!=self3;) { System.out.print("请输入修改密码:\n"); self2=input.next(); System.out.print("请输入确认密码:\n"); self2=input.next(); if(self2!=self3) {System.out.print("两次输入不匹配,请重新输入\n");} } accountinformation[sum].accountID=self2; System.out.print("****************************************************************"); break; case 5: System.out.print("***************************************************************\n" + "欢迎"+accountinformation[sum].accountname+"使用中国工商银行自助柜员系统\n" + "****************************************************************\n" + "当前账户余额为:"+accountinformation[sum].accountbalance+"元\n" + "账户清单信息为:\n"); byte[] byte3 = new byte[1024]; try { InputStream inp = System.in; while(inp.read() != -1){ String str = new String(byte3).trim(); } inp.close(); } catch (IOException e) {} break; } } } }
标签:pass oid stream ase his rate can ntp print
原文地址:https://www.cnblogs.com/Sakuraba/p/13715469.html