java如何实现银行管理系统-创新互联
本篇内容介绍了“java如何实现银行管理系统”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!
站在用户的角度思考问题,与客户深入沟通,找到昌吉网站设计与昌吉网站推广的解决方案,凭借多年的经验,让设计与互联网技术结合,创造个性化、用户体验好的作品,建站类型包括:成都网站设计、成都网站建设、外贸网站建设、企业官网、英文网站、手机端网站、网站推广、空间域名、网络空间、企业邮箱。业务覆盖昌吉地区。银行管理系统 (java实现),供大家参考,具体内容如下
1.创建一个封装类(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;}//定义一个数据类封装private String name;//名字private String account;//账号private int balance;//余额private String uesrpwds;//密码private String card;//身份证号private int id;//编号//封装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;}//封装账号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.实现增删改查等效果 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<>();//声明数组public static void main(String[] args) { Scanner sc = new Scanner(System.in); //初始化两个数据 Studentss studentss = new Studentss(); studentss.setName("张颖颖"); studentss.setAccount("17908064359"); studentss.setBalance(2000); studentss.setUesrpwds("4321"); studentss.setCard("510010619891231127"); list.add(studentss);//初始化数组 添加值 Studentss studentss1 = new Studentss(); studentss1.setName("刘华"); studentss1.setAccount("17908064368"); studentss1.setBalance(8000); studentss1.setUesrpwds("4567"); studentss1.setCard("410207198904051271"); list.add(studentss1);//初始化数组 添加值 // this.list =new ArrayList<>(); //String pass =input.lenth(); int input; //银行增删改查输出 System.out.println("账户姓名:张颖颖 账号: 17908064359 存款余额: 2000 密码:4321 身份证号:510010619891231127"); System.out.println("账户姓名:刘华 账号: 17908064368 存款余额: 8000 密码:4567 身份证号:410207198904051271"); do { System.out.println("=====================欢迎使用知道银行服务===================="); System.out.println("1:开户 2:存款 3: 取款 4: 转账 5:查余额 6:修改密码 0:退出"); System.out.println("==========================================================="); //判断输出选项 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://转账 Zhuangzhang(list); break; case 5://查询余额 Chaxun(list); break; case 6://修改密码 Changethepassword(list); break; case 0://退出 System.out.println("谢谢使用!"); break; default: System.out.println("请输入指定的命令语句!"); break; } }while (input != 0);}//开户public static void Openaccount(ArrayList list){ Studentss studentss =new Studentss(); int RDnum=(int)((Math.random()*9+1)*1000);//定义数据数 Scanner sc=new Scanner(System.in); System.out.println("请输入用户名:"); String name = sc.next(); studentss.setName(name);//接收输出 //list.add(studentss.getName());//存储数据 System.out.println("请输入账号密码:"); String uesrpwds=sc.next(); studentss.setUesrpwds(uesrpwds);//接收输出 //list.add(studentss.getUesrpwds());//存储数据 System.out.println("请输入身份证号:"); String card= sc.next(); studentss.setCard(card);//接收输出 //list.add(studentss.getCard());//存储数据 System.out.println("请输入金额:"); int balance=sc.nextInt(); studentss.setBalance(balance);//接收输出 //list.add(studentss.getBalance());//存储数据 String account="1790806"+RDnum; //账号: studentss.setAccount(account);//接收输出 //list.add(studentss.getAccount());//存储数据 System.out.println("账号:"+account); System.out.println("账号名:"+name); System.out.println("余额:"+balance); System.out.println("创建成功!"); list.add(studentss); } //查询金额 public static void Chaxun(ArrayList list) { Scanner cx2 = new Scanner(System.in); System.out.println("请输入账号:"); String account = cx2.next(); System.out.println("请输入账号密码:"); Scanner mc2 = new Scanner(System.in); String uesrpwds = cx2.next(); Iterator iterator = list.iterator(); while (iterator.hasNext()) {//判断是否存在下一个对象元素 Studentss studentss = (Studentss) iterator.next();//获取下一元素 if (account.equals(studentss.getAccount()) && uesrpwds.equals(studentss.getUesrpwds())) { System.out.println("账号的金额为:" + studentss.getBalance()); break; } } }//存款public static void CunKuang(ArrayList list){ //对象 // Studentss studentss= new Studentss(); System.out.println("请输入账号:"); 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("请输入存款金额:"); 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("查无账号!"); }}}//取款public static void Qukuang(ArrayList list){ Scanner cx = new Scanner(System.in); System.out.println("请输入账号:"); String account =cx.next(); Scanner mc = new Scanner(System.in); System.out.println("请输入账号密码:"); String uesrpwds =mc.next(); //迭代器 Iterator iterator = list.iterator(); while (iterator.hasNext()){//判断是否存在下一个对象元素 Studentss studentss =(Studentss) iterator.next();//获取下一元素 //判断密码账号是否存在相等 if(account.equals(studentss.getAccount())&&uesrpwds.equals(studentss.getUesrpwds())) { System.out.println("请输入取款金额:"); 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("账号或者密码不存在!"); } } }}//转账public static void Zhuangzhang(ArrayList list){ Scanner input = new Scanner(System.in);// 赋值一个输入值 System.out.println("请输入转出账号:"); String account =input.next(); System.out.println("请输入转出账户密码:"); String pwd1=input.next(); System.out.println("请输入转入账号:"); String account1=input.next(); //迭代器 Iterator iterator=list.iterator(); while (iterator.hasNext()){ Studentss studentss=iterator.next(); //判断转出账户是否存在 if (account.equals(studentss.getAccount())&&pwd1.equals(studentss.getUesrpwds()) ) { System.out.println("请输入转出金额"); int moneys=input.nextInt(); //判断转出账户金额是否大于或小于所需要金额 if (studentss.getBalance()>=moneys){ //迭代器在迭代一次 Iterator iterator1=list.iterator(); while (iterator1.hasNext()){ Studentss studentss1=iterator1.next(); //判断转入账户是否存在 if (account1.equals(studentss1.getAccount())&&account!=account1){ //满足条件转出账户扣除金额 studentss.setBalance(studentss.getBalance()-moneys); //满足条件转入账户存入金额 studentss1.setBalance(studentss1.getBalance()+moneys); System.out.println("转账成功,转出账号:" +studentss.getAccount()+ "转出金额:" +studentss.getBalance() +"转入账号:" +studentss1.getAccount()+ "转入金额" +studentss1.getBalance()); break; } } break; } else { System.out.println("转账失败!余额为:"+studentss.getBalance()); } break; } else { if(iterator.hasNext()==false){ System.out.println("请输入正确账户!"); } } }}//修改密码public static void Changethepassword(ArrayList list){ System.out.println("请输入账号:"); Scanner cx = new Scanner(System.in); String account =cx.next(); System.out.println("请输入账号原密码:"); Scanner mc = new Scanner(System.in); String uesrpwds =mc.next(); //迭代器 Iterator iterator = list.iterator(); while (iterator.hasNext()){//判断是否存在下一个对象元素 Studentss studentss =(Studentss) iterator.next();//获取下一元素 //判断密码账号是否存在相等 if(account.equals(studentss.getAccount())&&uesrpwds.equals(studentss.getUesrpwds())) { Scanner mc1 = new Scanner(System.in); System.out.println("请输入账号新密码:"); String uesrpwds1 =mc1.next(); Scanner mc2 = new Scanner(System.in); System.out.println("请再次输入新密码:"); String uesrpwds2 =mc2.next(); if (uesrpwds1.equals(uesrpwds2)) { studentss.setUesrpwds(uesrpwds1); System.out.println("账号修改密码成功!"); break; }else { System.out.println("两次密码不一样"); break; } }else { if(iterator.hasNext()==false){ System.out.println("请输入正确账户或密码!"); } } }}}
“java如何实现银行管理系统”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注创新互联网站,小编将为大家输出更多高质量的实用文章!
网页题目:java如何实现银行管理系统-创新互联
文章路径:http://ybzwz.com/article/dphchg.html