這篇文章將為大家詳細(xì)講解有關(guān)java銀行管理系統(tǒng)的實(shí)現(xiàn),文章內(nèi)容質(zhì)量較高,因此小編分享給大家做個(gè)參考,希望大家閱讀完這篇文章后對(duì)相關(guān)知識(shí)有一定的了解。
韶關(guān)網(wǎng)站建設(shè)公司成都創(chuàng)新互聯(lián),韶關(guān)網(wǎng)站設(shè)計(jì)制作,有大型網(wǎng)站制作公司豐富經(jīng)驗(yàn)。已為韶關(guān)上千余家提供企業(yè)網(wǎng)站建設(shè)服務(wù)。企業(yè)網(wǎng)站搭建\外貿(mào)網(wǎng)站制作要多少錢,請(qǐng)找那個(gè)售后服務(wù)好的韶關(guān)做網(wǎng)站的公司定做!1.創(chuàng)建一個(gè)封裝類(Studentss)
import javax.naming.Name; import javax.naming.NamingEnumeration; public class Studentss { //無(wú)參 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) //封裝id public int getId(){ return id; } public void setId(int id) { this.id = id; } //封裝名字get public String getName(){ return name; } public void setName(String name) { this.name = name; } //封裝賬號(hào)get public String getAccount(){ return account; } public void setAccount(String account) { this.account = account; } //封裝余額get public int getBalance() { return balance; } public void setBalance(int balance) { this.balance = balance; } //封裝密碼get public String getUesrpwds() { return uesrpwds; } public void setUesrpwds(String uesrpwds) { this.uesrpwds = uesrpwds; } //封裝身份證get public String getCard() { return card; } //set身份證 public void setCard(String card) { this.card = card; } @Override public 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 ArrayList<Studentss> list =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)輸入指定的命令語(yǔ)句!"); break; } }while (input != 0); } //開戶 public static void Openaccount(ArrayList<Studentss> 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<Studentss> 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<Studentss> 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<Studentss> list){ //對(duì)象 // Studentss studentss= new Studentss(); System.out.println("請(qǐng)輸入賬號(hào):"); Scanner cx = new Scanner(System.in); String account =cx.next(); Iterator<Studentss> 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("查無(wú)賬號(hào)!"); } } } //取款 public static void Qukuang(ArrayList<Studentss> 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<Studentss> 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("取款失?。?quot;); }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<Studentss> 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<Studentss> 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<Studentss> 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)輸入正確賬戶或密碼!"); } } } } }
關(guān)于java銀行管理系統(tǒng)的實(shí)現(xiàn)就分享到這里了,希望以上內(nèi)容可以對(duì)大家有一定的幫助,可以學(xué)到更多知識(shí)。如果覺得文章不錯(cuò),可以把它分享出去讓更多的人看到。
另外有需要云服務(wù)器可以了解下創(chuàng)新互聯(lián)建站jinyejixie.com,海內(nèi)外云服務(wù)器15元起步,三天無(wú)理由+7*72小時(shí)售后在線,公司持有idc許可證,提供“云服務(wù)器、裸金屬服務(wù)器、高防服務(wù)器、香港服務(wù)器、美國(guó)服務(wù)器、虛擬主機(jī)、免備案服務(wù)器”等云主機(jī)租用服務(wù)以及企業(yè)上云的綜合解決方案,具有“安全穩(wěn)定、簡(jiǎn)單易用、服務(wù)可用性高、性價(jià)比高”等特點(diǎn)與優(yōu)勢(shì),專為企業(yè)上云打造定制,能夠滿足用戶豐富、多元化的應(yīng)用場(chǎng)景需求。
新聞名稱:java銀行管理系統(tǒng)的實(shí)現(xiàn)-創(chuàng)新互聯(lián)
當(dāng)前網(wǎng)址:http://jinyejixie.com/article12/dsisdc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營(yíng)銷推廣、品牌網(wǎng)站制作、定制網(wǎng)站、用戶體驗(yàn)、商城網(wǎng)站、建站公司
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來(lái)源: 創(chuàng)新互聯(lián)
猜你還喜歡下面的內(nèi)容