本篇內(nèi)容介紹了“java如何實(shí)現(xiàn)銀行管理系統(tǒng)”的有關(guān)知識(shí),在實(shí)際案例的操作過程中,不少人都會(huì)遇到這樣的困境,接下來就讓小編帶領(lǐng)大家學(xué)習(xí)一下如何處理這些情況吧!希望大家仔細(xì)閱讀,能夠?qū)W有所成!
站在用戶的角度思考問題,與客戶深入溝通,找到昌吉網(wǎng)站設(shè)計(jì)與昌吉網(wǎng)站推廣的解決方案,憑借多年的經(jīng)驗(yàn),讓設(shè)計(jì)與互聯(lián)網(wǎng)技術(shù)結(jié)合,創(chuàng)造個(gè)性化、用戶體驗(yàn)好的作品,建站類型包括:成都網(wǎng)站設(shè)計(jì)、成都網(wǎng)站建設(shè)、外貿(mào)網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣、空間域名、網(wǎng)絡(luò)空間、企業(yè)郵箱。業(yè)務(wù)覆蓋昌吉地區(qū)。銀行管理系統(tǒng) (java實(shí)現(xiàn)),供大家參考,具體內(nèi)容如下
1.創(chuàng)建一個(gè)封裝類(Studentss)
import javax.naming.Name;import javax.naming.NamingEnumeration; public class Studentss {//無參public Studentss(){}//有參public Studentss(String name,String account,int balance,String uesrpwds,String card){ super(); this.name=name; this.account=account; this.balance=balance; this.uesrpwds=uesrpwds; this.card=card;}//修改public Studentss(String name,String account,int balance,String uesrpwds,String card,int id){ super(); this.name=name; this.account=account; this.balance=balance; this.uesrpwds=uesrpwds; this.card=card; this.id = id;}//定義一個(gè)數(shù)據(jù)類封裝private String name;//名字private String account;//賬號(hào)private int balance;//余額private String uesrpwds;//密碼private String card;//身份證號(hào)private int id;//編號(hào)//封裝idpublic int getId(){ return id;}public void setId(int id) { this.id = id;}//封裝名字getpublic String getName(){ return name;} public void setName(String name) { this.name = name;}//封裝賬號(hào)getpublic String getAccount(){ return account;}public void setAccount(String account) { this.account = account;}//封裝余額getpublic int getBalance() { return balance;}public void setBalance(int balance) { this.balance = balance;}//封裝密碼getpublic String getUesrpwds() { return uesrpwds;}public void setUesrpwds(String uesrpwds) { this.uesrpwds = uesrpwds;}//封裝身份證getpublic String getCard() { return card;}//set身份證public void setCard(String card) { this.card = card;}@Overridepublic String toString() { return super.toString();}}
2.實(shí)現(xiàn)增刪改查等效果 main方法(DoemTest)
import com.sun.org.apache.xpath.internal.objects.XObject;import java.util.ArrayList;import java.util.Iterator;import java.util.List;import java.util.Scanner;public class DoemTest{public static ArrayListlist =new ArrayList<>();//聲明數(shù)組public static void main(String[] args) { Scanner sc = new Scanner(System.in); //初始化兩個(gè)數(shù)據(jù) Studentss studentss = new Studentss(); studentss.setName("張穎穎"); studentss.setAccount("17908064359"); studentss.setBalance(2000); studentss.setUesrpwds("4321"); studentss.setCard("510010619891231127"); list.add(studentss);//初始化數(shù)組 添加值 Studentss studentss1 = new Studentss(); studentss1.setName("劉華"); studentss1.setAccount("17908064368"); studentss1.setBalance(8000); studentss1.setUesrpwds("4567"); studentss1.setCard("410207198904051271"); list.add(studentss1);//初始化數(shù)組 添加值 // this.list =new ArrayList<>(); //String pass =input.lenth(); int input; //銀行增刪改查輸出 System.out.println("賬戶姓名:張穎穎 賬號(hào): 17908064359 存款余額: 2000 密碼:4321 身份證號(hào):510010619891231127"); System.out.println("賬戶姓名:劉華 賬號(hào): 17908064368 存款余額: 8000 密碼:4567 身份證號(hào):410207198904051271"); do { System.out.println("=====================歡迎使用知道銀行服務(wù)===================="); System.out.println("1:開戶 2:存款 3: 取款 4: 轉(zhuǎn)賬 5:查余額 6:修改密碼 0:退出"); System.out.println("==========================================================="); //判斷輸出選項(xiàng) Scanner set = new Scanner(System.in);//接受輸入的值(0~6); input =set.nextInt(); switch (input){ case 1://開戶 Openaccount(list); break; case 2://存款 CunKuang(list); break; case 3://取款 Qukuang(list); break; case 4://轉(zhuǎn)賬 Zhuangzhang(list); break; case 5://查詢余額 Chaxun(list); break; case 6://修改密碼 Changethepassword(list); break; case 0://退出 System.out.println("謝謝使用!"); break; default: System.out.println("請(qǐng)輸入指定的命令語句!"); break; } }while (input != 0);}//開戶public static void Openaccount(ArrayList list){ Studentss studentss =new Studentss(); int RDnum=(int)((Math.random()*9+1)*1000);//定義數(shù)據(jù)數(shù) Scanner sc=new Scanner(System.in); System.out.println("請(qǐng)輸入用戶名:"); String name = sc.next(); studentss.setName(name);//接收輸出 //list.add(studentss.getName());//存儲(chǔ)數(shù)據(jù) System.out.println("請(qǐng)輸入賬號(hào)密碼:"); String uesrpwds=sc.next(); studentss.setUesrpwds(uesrpwds);//接收輸出 //list.add(studentss.getUesrpwds());//存儲(chǔ)數(shù)據(jù) System.out.println("請(qǐng)輸入身份證號(hào):"); String card= sc.next(); studentss.setCard(card);//接收輸出 //list.add(studentss.getCard());//存儲(chǔ)數(shù)據(jù) System.out.println("請(qǐng)輸入金額:"); int balance=sc.nextInt(); studentss.setBalance(balance);//接收輸出 //list.add(studentss.getBalance());//存儲(chǔ)數(shù)據(jù) String account="1790806"+RDnum; //賬號(hào): studentss.setAccount(account);//接收輸出 //list.add(studentss.getAccount());//存儲(chǔ)數(shù)據(jù) System.out.println("賬號(hào):"+account); System.out.println("賬號(hào)名:"+name); System.out.println("余額:"+balance); System.out.println("創(chuàng)建成功!"); list.add(studentss); } //查詢金額 public static void Chaxun(ArrayList list) { Scanner cx2 = new Scanner(System.in); System.out.println("請(qǐng)輸入賬號(hào):"); String account = cx2.next(); System.out.println("請(qǐng)輸入賬號(hào)密碼:"); Scanner mc2 = new Scanner(System.in); String uesrpwds = cx2.next(); Iterator iterator = list.iterator(); while (iterator.hasNext()) {//判斷是否存在下一個(gè)對(duì)象元素 Studentss studentss = (Studentss) iterator.next();//獲取下一元素 if (account.equals(studentss.getAccount()) && uesrpwds.equals(studentss.getUesrpwds())) { System.out.println("賬號(hào)的金額為:" + studentss.getBalance()); break; } } }//存款public static void CunKuang(ArrayList list){ //對(duì)象 // Studentss studentss= new Studentss(); System.out.println("請(qǐng)輸入賬號(hào):"); Scanner cx = new Scanner(System.in); String account =cx.next(); Iterator iterator = list.iterator(); while (iterator.hasNext()){ Studentss studentss =(Studentss) iterator.next(); if (account.equals(studentss.getAccount())){ System.out.println("請(qǐng)輸入存款金額:"); Scanner cxc =new Scanner(System.in); int num = cxc.nextInt(); if (num >= 0) { studentss.setBalance(studentss.getBalance()+num); System.out.println("存款成功!余額為:"+studentss.getBalance()); break; }else { System.out.println("存款失敗!余額為:"+studentss.getBalance()); break; } } else { } if(iterator.hasNext() ==false){ System.out.println("查無賬號(hào)!"); }}}//取款public static void Qukuang(ArrayList list){ Scanner cx = new Scanner(System.in); System.out.println("請(qǐng)輸入賬號(hào):"); String account =cx.next(); Scanner mc = new Scanner(System.in); System.out.println("請(qǐng)輸入賬號(hào)密碼:"); String uesrpwds =mc.next(); //迭代器 Iterator iterator = list.iterator(); while (iterator.hasNext()){//判斷是否存在下一個(gè)對(duì)象元素 Studentss studentss =(Studentss) iterator.next();//獲取下一元素 //判斷密碼賬號(hào)是否存在相等 if(account.equals(studentss.getAccount())&&uesrpwds.equals(studentss.getUesrpwds())) { System.out.println("請(qǐng)輸入取款金額:"); Scanner mcx =new Scanner(System.in); int mic =mcx.nextInt(); studentss.setBalance(studentss.getBalance()-mic); if (mic>studentss.getBalance()){ System.out.println("取款失??!"); }else { System.out.println("取款成功!余額為:"+studentss.getBalance()); } break; }else { if(iterator.hasNext() ==false){ System.out.println("賬號(hào)或者密碼不存在!"); } } }}//轉(zhuǎn)賬public static void Zhuangzhang(ArrayList list){ Scanner input = new Scanner(System.in);// 賦值一個(gè)輸入值 System.out.println("請(qǐng)輸入轉(zhuǎn)出賬號(hào):"); String account =input.next(); System.out.println("請(qǐng)輸入轉(zhuǎn)出賬戶密碼:"); String pwd1=input.next(); System.out.println("請(qǐng)輸入轉(zhuǎn)入賬號(hào):"); String account1=input.next(); //迭代器 Iterator iterator=list.iterator(); while (iterator.hasNext()){ Studentss studentss=iterator.next(); //判斷轉(zhuǎn)出賬戶是否存在 if (account.equals(studentss.getAccount())&&pwd1.equals(studentss.getUesrpwds()) ) { System.out.println("請(qǐng)輸入轉(zhuǎn)出金額"); int moneys=input.nextInt(); //判斷轉(zhuǎn)出賬戶金額是否大于或小于所需要金額 if (studentss.getBalance()>=moneys){ //迭代器在迭代一次 Iterator iterator1=list.iterator(); while (iterator1.hasNext()){ Studentss studentss1=iterator1.next(); //判斷轉(zhuǎn)入賬戶是否存在 if (account1.equals(studentss1.getAccount())&&account!=account1){ //滿足條件轉(zhuǎn)出賬戶扣除金額 studentss.setBalance(studentss.getBalance()-moneys); //滿足條件轉(zhuǎn)入賬戶存入金額 studentss1.setBalance(studentss1.getBalance()+moneys); System.out.println("轉(zhuǎn)賬成功,轉(zhuǎn)出賬號(hào):" +studentss.getAccount()+ "轉(zhuǎn)出金額:" +studentss.getBalance() +"轉(zhuǎn)入賬號(hào):" +studentss1.getAccount()+ "轉(zhuǎn)入金額" +studentss1.getBalance()); break; } } break; } else { System.out.println("轉(zhuǎn)賬失敗!余額為:"+studentss.getBalance()); } break; } else { if(iterator.hasNext()==false){ System.out.println("請(qǐng)輸入正確賬戶!"); } } }}//修改密碼public static void Changethepassword(ArrayList list){ System.out.println("請(qǐng)輸入賬號(hào):"); Scanner cx = new Scanner(System.in); String account =cx.next(); System.out.println("請(qǐng)輸入賬號(hào)原密碼:"); Scanner mc = new Scanner(System.in); String uesrpwds =mc.next(); //迭代器 Iterator iterator = list.iterator(); while (iterator.hasNext()){//判斷是否存在下一個(gè)對(duì)象元素 Studentss studentss =(Studentss) iterator.next();//獲取下一元素 //判斷密碼賬號(hào)是否存在相等 if(account.equals(studentss.getAccount())&&uesrpwds.equals(studentss.getUesrpwds())) { Scanner mc1 = new Scanner(System.in); System.out.println("請(qǐng)輸入賬號(hào)新密碼:"); String uesrpwds1 =mc1.next(); Scanner mc2 = new Scanner(System.in); System.out.println("請(qǐng)?jiān)俅屋斎胄旅艽a:"); String uesrpwds2 =mc2.next(); if (uesrpwds1.equals(uesrpwds2)) { studentss.setUesrpwds(uesrpwds1); System.out.println("賬號(hào)修改密碼成功!"); break; }else { System.out.println("兩次密碼不一樣"); break; } }else { if(iterator.hasNext()==false){ System.out.println("請(qǐng)輸入正確賬戶或密碼!"); } } }}}
“java如何實(shí)現(xiàn)銀行管理系統(tǒng)”的內(nèi)容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業(yè)相關(guān)的知識(shí)可以關(guān)注創(chuàng)新互聯(lián)網(wǎng)站,小編將為大家輸出更多高質(zhì)量的實(shí)用文章!