时间:2021-05-19
银行管理系统 (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 ArrayList<Studentss> list =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<Studentss> 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<Studentss> 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<Studentss> 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<Studentss> list){ //对象 // Studentss studentss= new Studentss(); System.out.println("请输入账号:"); 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("请输入存款金额:"); 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<Studentss> 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<Studentss> 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<Studentss> 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<Studentss> 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<Studentss> 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("请输入正确账户或密码!"); } } }}}注:(我的代码可以有些的纰漏,问题不是很大,基本逻辑写的差不多了,如果有问题,评论下,我虚心请教,希望我们的代码之路会越走越远!加油)
关于管理系统的更多内容请点击《管理系统专题》进行学习
以上就是本文的全部内容,希望对大家的学习有所帮助,也希望大家多多支持。
声明:本页内容来源网络,仅供用户参考;我单位不保证亦不表示资料全面及准确无误,也不保证亦不表示这些资料为最新信息,如因任何原因,本网内容或者用户因倚赖本网内容造成任何损失或损害,我单位将不会负任何法律责任。如涉及版权问题,请提交至online#300.cn邮箱联系删除。
本文实例为大家分享了java银行管理系统的具体代码,供大家参考,具体内容如下账户类packageAccount;publicabstractclassAccou
管理信息系统包括邮电信息系统、银行管理信息系统、民航信息系统、企业管理信息系统、医院管理信息系统等。 管理信息系统(ManagementInformation
python实现银行管理系统,供大家参考,具体内容如下有的地方用的方法的比较复杂,主要是为回顾更多的知识test1用来存类和函数#test1.pyimportr
本文为大家分享了python银行管理系统的具体代码,供大家参考,具体内容如下自己写的练手小程序,练习面向对象的概念,代码中都有注释,刚学的同学也可以很容易看懂(
本文为大家分享了C语言银行储蓄系统源码,实现银行的各项功能,供大家参考,具体内容如下#include#include#include#includevoidop