复利存款java源代码

合集下载

java优秀代码案例

java优秀代码案例

java优秀代码案例
在Java中,有许多优秀的代码案例可供学习。

以下是一些例子:
1. Java Collections Framework: Java的集合框架是一个很好的例子,它展示了如何使用接口和抽象类来创建一个可扩展的系统。

Java集合框架主要
包括两种类型的集合:Collection和Map。

2. Java I/O 库: Java的I/O库也是非常值得学习的。

它提供了许多类和接口,用于处理文件输入和输出,网络通信,数据序列化等。

3. Spring框架: Spring框架是一个非常流行的Java框架,用于构建企业级应用程序。

它是一个开源的Java平台,提供了一种全面的编程和配置模型,用于构建企业级应用程序。

Spring框架的核心是依赖注入和面向切面编程。

4. JUnit: JUnit是一个Java编程语言的单元测试框架。

它用于对Java类进
行单元测试,并帮助开发人员编写可重复的测试。

JUnit是开源的,并且是
极限编程和许多其他方法论的核心工具。

5. Apache Commons Lang: Apache Commons Lang是一个Java核心库,提供了一些实用的工具类和实用程序,用于处理常见的Java类。

这个库包
括字符串处理,日期处理,数学等。

以上都是一些非常优秀的Java代码案例,可以帮助你提高编程技能和编写
更好的代码。

java项目 ATM银行系统 源代码

java项目 ATM银行系统 源代码

//初始密码为123456import java.awt.*;import java.awt.event.*;import javax.swing.*;public class MyATM extends JFrame implements ActionListener{ JPanelpanelfirst,panelmain,panel3,panel4,panel5,panel6,panel7,panelchangepw d,panelchangepwded,panelsave,panelsaved,panelremain,paneltrans,panelt ransed,panelmobile,panelmobiled,panelconsult;JButtonbtn0,btn1,btn2,btn3,btn4,btn5,btn6,btn7,btn8,btn9,btn10,btnsure,btnba ck,btnok,btncard,btngetcard,btnincard;JButtonbtn00,btn01,btn02,btn03,btn04,btn05,btn06,btn07,btn08,btn09,btn010,bt nback1,btnremain,btnremain1,btnremain2;JButtonbtn000,btn001,btn002,btn003,btn004,btn005,btn006,btn007,btn008,btn009 ,btn100,btn200,btn300,btn1000,btn500,btnsure1,btnback2,btn0010,btnquo k1,btnquok2,btnquok3,btnquok4;JButtonbtnpwd,btnpwd1,btnpwd2,btnpwd3,btnpwd4,btn11,btn12,btn13,btn14,btn15, btn16,btn17,btn18,btn19,btn20,btnsave,btnsave1,btnsave2,btnsaved,btns aved1,btnsaved2,btnsaved3;JButtonbtntra,btntra1,btntra2,btntraed,btntraed1,btn21,btn22,btn23,btn24,btn 25,btn26,btn27,btn28,btn29,btn30,btncon,btncon1;JButtonbtnmo,btnmo1,btnmo2,btnmo30,btnmo50,btnmo100,btnmo200,btnmo500,btnmo1 0,btnmo11,btnmo12,btnmo13,btnmo14,btnmo15,btnmo16,btnmo17,btnmo18,btn mo19,btnmoed,btnmoed1;JTextField txt2,txttrans,txttrans1,txttrans2,txtmo,txtmo1;JLabellbljixu,lblpwd,lblwrong,lblqukuan,lblquok1,lblquok2,lblpwd1,lblpwd2,l blpwd3,lblpwd4,lblsave,lblsave1,lblsaved,lblremain,lblremain1,lbltra, lbltra1,lbltra2,lbltraed,lbltraed1;JLabellblwel,lblwel1,lblmo,lblmo1,lblmo2,lblmo3,lblmoed,lblmoed1,lblcon,lbl con1;JPasswordField txt1,txtpwd,txtpwd1;Container container;CardLayout Layout;int money,savemoney,mobilemoney=0;double lastmoney,trainsmoney;String userpwd,cardnum,trains,username;booleanflag=true,flag1=false,flag2=false,flag3=true,flag4=false,flag5=false;//构造方法public MyATM(){super("罗灿银行");this.setSize(435,350);this.setLocation(500, 250);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );//设置不可改变窗口大小this.setResizable(false);//设置程序小图标this.setIconImage(this.getToolkit().getImage("images\\haizei.jpg" ));}//布局public void setLayout(){//用卡片布局Layout=new CardLayout();container=getContentPane();container.setLayout(Layout);//添加第一张卡片panelfirst=new JPanel(null);//设置卡片的背景颜色panelfirst.setBackground(new Color(119,119,253));lbljixu=new JLabel("请放入磁卡,然后继续操作");//设置卡片在Panel中的位置lbljixu.setBounds(140,90,350,30);//为第一张卡片添加一个Labelpanelfirst.add(lbljixu);//为第一张卡片添加一个按钮btncard=new JButton("继续");btncard.setBounds(310,180,80,30);//为按钮注册事件监听器btncard.addActionListener(this);//开始时设置按钮不可按btncard.setEnabled(false);panelfirst.add(btncard);//为第一张卡片添加一个按钮btngetcard=new JButton("取卡");btngetcard.setEnabled(false);btngetcard.setBounds(310,220,80,30);btngetcard.addActionListener(this);panelfirst.add(btngetcard);//为第一张卡片添加一个按钮btnincard=new JButton("插卡");btnincard.setBounds(40,220,80,30);btnincard.addActionListener(this);panelfirst.add(btnincard);container.add(panelfirst,"first");//添加登录输入密码卡片panelmain=new JPanel(null);panelmain.setBackground(new Color(119,119,253)); lblpwd=new JLabel("请输入您的银行卡密码:"); panelmain.add(lblpwd);lblpwd.setBounds(150, 20, 150, 30);//设置文本框为密码型txt1=new JPasswordField(12);//文本框不可选中txt1.enable(false);panelmain.add(txt1);//文本框的输入内容用*显示txt1.setEchoChar('*');txt1.setBounds(115,50,200,30);//添加选择按钮btnsure=new JButton("确定");btnsure.addActionListener(this);panelmain.add(btnsure);btnsure.setBounds(70,160,80,30);//添加重输按钮btn010=new JButton("重输");btn010.addActionListener(this);panelmain.add(btn010);btn010.setBounds(175,160,80,30);btnback=new JButton("退出");btnback.addActionListener(this); panelmain.add(btnback);btnback.setBounds(280,160,80,30);lblwrong=new JLabel("请注意保护好您的密码!"); panelmain.add(lblwrong);lblwrong.setBounds(150,90,200,30);//添加输入按钮btn01=new JButton("1");btn01.addActionListener(this);panelmain.add(btn01);btn01.setBounds(45,210,60,30);btn02=new JButton("2");btn02.addActionListener(this);panelmain.add(btn02);btn02.setBounds(115,210,60,30);btn03=new JButton("3");btn03.addActionListener(this);panelmain.add(btn03);btn03.setBounds(185,210,60,30);btn04=new JButton("4");btn04.addActionListener(this);panelmain.add(btn04);btn04.setBounds(255,210,60,30);btn05=new JButton("5");btn05.addActionListener(this);panelmain.add(btn05);btn05.setBounds(325,210,60,30);btn06=new JButton("6");btn06.addActionListener(this);panelmain.add(btn06);btn06.setBounds(45,260,60,30);btn07=new JButton("7");btn07.addActionListener(this);panelmain.add(btn07);btn07.setBounds(115,260,60,30);container.add(panelmain,"main");btn08=new JButton("8");btn08.addActionListener(this);panelmain.add(btn08);btn08.setBounds(185,260,60,30);btn09=new JButton("9");btn09.addActionListener(this);panelmain.add(btn09);btn09.setBounds(255,260,60,30);btn00=new JButton("0");btn00.addActionListener(this);panelmain.add(btn00);btn00.setBounds(325,260,60,30);//添加主界面卡片panel3=new JPanel(null);panel3.setBackground(new Color(119,119,253));lblwel=new JLabel(username+",欢迎使用罗灿银行ATM系统"); lblwel.setBounds(20,15,350,30);panel3.add(lblwel);lblwel1=new JLabel("请选择您需要的交易类型");lblwel1.setBounds(220,55,350,30);panel3.add(lblwel1);btn3=new JButton("取款服务");btn3.addActionListener(this);btn3.setBounds(20,90,100,30);panel3.add(btn3);btn4=new JButton("修改密码");btn4.addActionListener(this);btn4.setBounds(20,150,100,30);panel3.add(btn4);btn5=new JButton("存款服务");btn5.addActionListener(this);btn5.setBounds(20,210,100,30);panel3.add(btn5);btn6=new JButton("查询余额");btn6.addActionListener(this);btn6.setBounds(20,270,100,30);panel3.add(btn6);btn7=new JButton("转账服务");btn7.addActionListener(this);btn7.setBounds(300,90,100,30);panel3.add(btn7);btn8=new JButton("通信交费");btn8.addActionListener(this);btn8.setBounds(300,150,100,30);panel3.add(btn8);btn9=new JButton("咨询服务");btn9.addActionListener(this);btn9.setBounds(300,210,100,30);panel3.add(btn9);btn10=new JButton("退出操作");btn10.addActionListener(this);btn10.setBounds(300,270,100,30);panel3.add(btn10);container.add(panel3,"three");//添加取款页面卡片panel4=new JPanel(null);panel4.setBackground(new Color(119,119,253));lblqukuan=new JLabel("请输入您的取款数:");panel4.add(lblqukuan);lblqukuan.setBounds(115, 20, 150, 30);lblqukuan=new JLabel("提示:只能是100元或100元的整数倍。

Java面向对象源代码(银行业务案例)

Java面向对象源代码(银行业务案例)

1.创建Bankl类,注意银行的账户名、密码、余额等信息私有化public class Bank {static String bankName;private String name;private String password;private double banlace;//账户余额private double turnover;//交易额static void welcome(){System.out.println("欢迎来到"+bankName);}public Bank(String name,String password,double turnover) { =name;this.password=password;this.turnover=turnover;this.banlace=turnover-10;}public void deposit(String password,double turnover) { if(this.password!=password) {System.out.println("密码错误!");}else{banlace=banlace+turnover;System.out.println(name+"您好,您的账户已存入"+turnover+"元,"+"当前余额是"+banlace);}}public void withdrawl(String password,double turnover) { if(this.password!=password) {System.out.println("密码错误!");}else if(banlace-turnover>0) {banlace=banlace-turnover;System.out.println(name+"您好,您的账户已取出"+turnover+"元,"+"当前余额是"+banlace);}else {System.out.println("对不起,余额不足!");}}static void welcomeNext(){System.out.println("欢迎下次光临!");}}2.创建交易测试类public class Trade {public static void main(String[] args) { Bank.bankName="招商银行";Bank.welcome();Bank bank=new Bank("张三","123456",100.0);bank.deposit("465466",500.0);bank.withdrawl("654321", 230);bank.withdrawl("123456", 630);bank.withdrawl("123456", 200);Bank.welcomeNext();}}。

java银行家算法代码实现

java银行家算法代码实现

java银行家算法代码实现=================一、算法简介------银行家算法是一种用于避免系统发生死锁的算法,它通过分析系统资源分配情况,判断系统是否处于安全状态,从而避免死锁的发生。

Java银行家算法是一种基于Java语言的实现,它通过模拟系统资源分配情况,判断系统是否处于安全状态。

二、算法实现------以下是一个简单的Java银行家算法代码实现:```javapublicclassBankerAlgorithm{//资源数量和最大需求量privateint[]resource=newint[10];//例如:包括x,y,z三种资源,分别对应i-x1-x2-z...-xi-yi-zi...privateint[]maxDemand=newint[10];privateint[]available=newint[10];//当前可用资源数量privateint[]allocation=newint[10];//当前已分配资源数量privateint[]need=newint[10];//当前进程需求量privateint[]saved=newint[10];//已保存的安全序列中最后一个进程的资源需求量privateint[]process=newint[5];//进程集合,包括进程编号和进程所需资源量privateint[]processMax=newint[5];//进程最大需求量集合privateint[]systemSafe=0;//系统是否处于安全状态的标志位privateinttotalSystemSafe=0;//总共是否有足够资源可以安全运行的标志位//初始化资源分配信息publicvoidinitialize(int[][]allocationMatrix){for(inti=0;i<allocationMatrix.length;i++){process[i]=allocationMatrix[i][0];//进程编号processMax[i]=allocationMatrix[i][1];//进程最大需求量available[i]=allocationMatrix[i][2];//当前可用资源数量need[i]=allocationMatrix[i][3];//当前进程需求量maxDemand[i]=allocationMatrix[i][4];//当前进程最大需求量}systemSafe=true;//系统默认处于安全状态totalSystemSafe=true;//总共是否有足够资源可以安全运行的标志位默认设置为true}//检查系统是否处于安全状态,并返回检查结果和可能的执行序列(从开始到结束)publicboolean[]checkAndPrintSafePath(){intcurrentSystemSafe=false;//检查后的系统是否处于安全状态的标志位boolean[]safePath=newboolean[process.length];//安全序列for(inti=0;i<process.length;i++){if(need[i]<=available[i]){//如果当前进程需要的资源小于等于当前可用资源数量,则可以继续执行下去safePath[i]=true;//将当前进程标记为已执行过,并加入到安全序列中available[i]-=need[i];//将当前可用资源数量减去当前进程的已分配量,表示系统多出来的资源数量为已分配的减去需求的currentSystemSafe=true;//将当前系统的安全状态标记为true,因为已经有至少一个进程能够执行下去了}else{//如果当前进程需要的资源大于当前可用资源数量,则需要检查系统是否有足够的资源可以继续执行下去intavailableSum=0;//系统剩余的可用资源数量之和for(intj=0;j<process.length;j++){//将所有可用资源的数量累加起来availableSum+=available[j];}if(availableSum>=processMax[i]){//如果系统剩余的可用资源数量之和大于等于当前进程的最大需求量,则系统可以继续执行下去,否则需要重新分配资源并返回结果重新开始执行安全序列为null;如果为空说明不满足要求否则输出一个安全的执行序列,开始输出可执行的进程数以及所分配的资源和后续的系统安全状态标记等信息totalSystemSafe=false;//将当前系统安全状态的标志位置为false,因为此时不满足安全状态的要求,需要重新开始执行程序,且此次循环的完整性和执行性需要考虑已经完成过的安全序列重新考虑这些因素的修改可能会被重用)确保安全性序列不再更改);再次输出完整的信息需要重新考虑这些因素以确保安全性序列不再更改)并返回结果;如果为true则说明系统已经处于安全状态并输出一个安全的执行序列;如果为false则说明。

JAVA编写的计算器源代码

JAVA编写的计算器源代码

JAVA编写的计算器源代码// Calculator.javaimport javax.swing.*; // 引入swing库import java.awt.*; // 引入awt库import java.awt.event.*; // 引入awt.event库public class Calculator extends JFrame implements ActionListener//定义按钮private JButton zero;private JButton one;private JButton two;private JButton three;private JButton four;private JButton five;private JButton six;private JButton seven;private JButton eight;private JButton nine;private JButton point;private JButton equal; private JButton plus; private JButton minus; private JButton multiply; private JButton divide; private JButton backspace; private JButton ac;private JButton ce;private JButton sqrt; private JButton sqr;private JButton plus_minus; private JButton delete; private JButton sin;private JButton cos;private JButton tan;private JButton log;private JButton nfactorial; private JButton cubic; private JButton coln;private JButton factorial;//定义文本框private JTextField resulttext;// 定义boolean变量boolean clrdisp = true; // 昵称确定是否清除计算器显示boolean isCalculate = false; // 是否可以执行计算// 定义String变量,用于存储操作符String optr;//定义存储第一个操作数double num1;//初始化构造函数public Calculato//设置布局setLayout(new BorderLayout();//创建面板JPanel northPanel = new JPanel(;JPanel centerPanel = new JPanel(;JPanel southPanel = new JPanel(;//设置面板布局northPanel.setLayout(new FlowLayout(); centerPanel.setLayout(new GridLayout(4, 5)); southPanel.setLayout(new FlowLayout();//设置计算器显示resulttext = new JTextField(28); northPanel.add(resulttext);resulttext.setEditable(false);//初始化按钮zero = new JButton("0");one = new JButton("1");two = new JButton("2");three = new JButton("3");four = new JButton("4");five = new JButton("5");six = new JButton("6");seven = new JButton("7");eight = new JButton("8");nine = new JButton("9");point = new JButton(".");equal = new JButton("=");plus = new JButton("+");minus = new JButton("-"); multiply = new JButton("*"); divide = new JButton("/"); backspace = new JButton("<-"); ac = new JButton("AC");ce = new JButton("CE");sqrt = new JButton("sqrt");sqr = new JButton("sqr");plus_minus = new JButton("+/-");。

简单复利计算java板

简单复利计算java板

简单复利计算java板⼀、要求:1.客户说:帮我开发⼀个复利计算软件。

2如果按照单利计算,本息⼜是多少呢?3.假如30年之后要筹措到300万元的养⽼⾦,平均的年回报率是3%,那么,现在必须投⼊的本⾦是多少呢?4.利率这么低,复利计算收益都这么厉害了,如果拿100万元去买年报酬率10%的股票,若⼀切顺利,过多长时间,100万元就变成200万元呢?5.如果我希望在⼗年内将100万元变成200万元,应该找到报酬率在多少的投资⼯具来帮助我达成⽬标?如果想在5年后本⾦翻倍,报酬率就应⾄少为多少才⾏呢?6.如果每年都将积蓄的3万元进⾏投资,每年都能获得3%的回报,然后将这些本利之和连同年⾦再投⼊新⼀轮的投资,那么,30年后资产总值将变为多少?如果换成每⽉定投3000呢?(定额定投收益计算办法)7. 你写的程序能让客户随意操作吗?误输⼊数据、不⼩⼼做了⾮常规的操作程序是什么反应?相互观赏程序运⾏情况。

8. 如果向银⾏贷款10万元,年利率6.5%,期限为10年,那么每⽉等额本息还款多少?(算复利条件下等额还款⾦额)⼆、使⽤⼯具和功能介绍1、⽤到语⾔是Java语⾔,⼯具:MyEclipse10,JDK:jdk1.6.0_232、根据界⾯提供的选择类型按钮可以选择,复利计算,单利计算,利率计算,根据利率,时间计算下⾯是界⾯的结果:三、对于⾮法输⼊的控制考虑到的⾮法输⼊有,某些项⽬不输⼊不输⼊⽽直接按确定,某些项⽬输⼊⾮数字等,我采取的措施是使⽤try_catch语句把它包围以来,字符不对的统⼀弹出⼀个⼩警告窗,提醒⽤户正确输⼊!具体效果如下图:三、具体的代码:1、因为具体的每个功能计算代码都差不多,所以只截取某个经过封装的计算函数,和“确定”按钮的监听事件。

如下图:总结:1.java编写的复利计算器和c++编出来的效果其实差不多,技术含量不是很⼤,预想两三个⼩时就能编写出来,但真正⽤时却是6h+,主要是因为java某些基本语法不是很记得,要⼀边编写程序,⼀边查有关的语法,还有就是对程序的调试也⽤了较多时间,所以这次给我的教训是多编写程序,让java基本的语法,相关知识的⽤法熟练掌握,⽽不是记得⼤概的样⼦。

java银行账户管理系统代码

java银行账户管理系统代码

Java银行账户管理系统代码简介银行账户管理系统是一个用于管理银行客户账户的软件系统。

该系统可以实现客户开户、存款、取款、转账等基本功能,同时提供了查询账户余额、查询交易记录等附加功能,便于客户管理自己的资金。

功能模块客户管理模块这个模块包括客户信息的增删改查功能。

系统可以记录客户的姓名、身份证号、手机号等基本信息。

账户管理模块这个模块包括账户的开户、销户、存款、取款、转账等功能。

代码实现客户类public class Customer {private String name;private String idCard;private String phoneNumber;// 构造方法public Customer(String name, String idCard, String phoneNumber) { = name;this.idCard = idCard;this.phoneNumber = phoneNumber;}// getter和setter方法public String getName() {return name;}public void setName(String name) { = name;}public String getIdCard() {return idCard;}public void setIdCard(String idCard) {this.idCard = idCard;}public String getPhoneNumber() {return phoneNumber;}public void setPhoneNumber(String phoneNumber) {this.phoneNumber = phoneNumber;}}账户类```java public class Account { private String accountNumber; private double balance; private Customer customer;// 构造方法public Account(String accountNumber, Customer customer) {this.accountNumber = accountNumber;this.customer = customer;}// 存款public void deposit(double amount) {balance += amount;}// 取款public void withdraw(double amount) {if (balance >= amount) {balance -= amount;} else {System.out.println(\。

Java语言编写实现银行账号开户_存款_取款和转账等功能

Java语言编写实现银行账号开户_存款_取款和转账等功能

Java语言编写实现银行账号开户、存款、取款、查询和转账源代码详解需求分析1.ATM柜员机系统保存所有开户用户的信息(银行卡号、密码、真实姓名、家庭地址、联系电话、卡内金额),限制最大开户数1002.用户通过开户能实现自助开户,银行卡号随机数生成5位整数,卡内金额默认为0,其他信息由客户在控制台上输入,要求银行卡号不能重复3.用户可以选择存款选项办理存款业务要求存款客户必须是已经在我行合法开户的用户,卡号、密码必须进过验证才能登录系统进行存款业务的办理,业务办理完毕后显示该客户目前的卡内余额信息并提示办理成功4.用户可以选择取款选择办理取款要求取款客户必须是已经在我行合法开户的用户,卡号、密码必须进过验证才能登录系统进行取款业务的办理,输入存款金额后,显示目前卡内余额信息并提示办理成功5.用户可以选择查询余额选择办理查询业务要求取款客户必须是已经在我行合法开户的用户,卡号、密码必须进过验证才能登录系统进行查询业务的办理,登录信息验证成功后显示该用户的详细信息6.用户可以选择转账选项办理查询业务[本系统只支持本地行内转账] 要求取款客户必须是已经在我行合法开户的用户,卡号、密码必须进过验证才能登录系统进行转账业务的办理,用户输入的转账帐号必须是已经在我行合法开户的用户,合法的转账帐号显示该用户姓名,输入转账金额,完成转账功能显示自己的卡内余额并提示业务办理成功7.用户选择退出,结束本次业务办理8.该项目中的相关逻辑判断请自行斟酌1.将用户的卡号、密码、姓名、手机号码、家庭住址和卡上余额属性封装成对象,代码如下package ;import .*;public class BankAccount{private int cardNum;private String passWord;private String name;private String address;private long telephone;private float money;public int getCardNum() {return cardNum;}public void setCardNum(int cardNum) { = cardNum;}public String getPassWord() {return passWord;}public void setPassWord(String passWord) { = passWord;}public String getName() {return name;}public void setName(String name) {= name;}public String getAddress() {return address;}public void setAddress(String address) { = address;}public long getTelephone() {return telephone;}public void setTelephone(long telephone) { = telephone;}public float getMoney() {return money;}public void setMoney(float money) { = money;}}2.建立测试类Junit Test文件package ;import static .*;import .*;import ;import ;import ;public class ATMTest {Scanner sn=new Scanner;List<BankAccount> clientList=new ArrayList<BankAccount>(); 户");("\t\t\t\t2.存款");("\t\t\t\t3.取款");("\t\t\t\t4.查询余额");("\t\t\t\t5.转账");("\t\t\t\t6.退出");("\t\t\t请输入您要办理的项目");int num=();if(num==1){openAccount();}else if(num==2){saveMoney();}else if(num==3){takeMoney();}else if(num==4){checkMoney();}else if(num==5){transferMoney();}else if(num==6){("退出");break;}else{("请输入正确的选项!!!");}}}public class BankAccount{private int cardNum;private String passWord;private String name;private String address;private long telephone;private double money;public int getCardNum() {return cardNum;}public void setCardNum(int cardNum) { = cardNum;}public String getPassWord() {return passWord;}public void setPassWord(String passWord) { = passWord;}public String getName() {return name;}public void setName(String name) {= name;}public String getAddress() {return address;}public void setAddress(String address) { = address;}public long getTelephone() {return telephone;}public void setTelephone(long telephone) { = telephone;}public double getMoney() {return money;}public void setMoney(double money) {= money;}}public void openAccount(){quals(passWord)){account_1=account;}else{account_1=null;}return account_1;}}。

JAVA实现账户取款和存款操作

JAVA实现账户取款和存款操作

JAVA实现账户取款和存款操作这篇⽂章主要介绍了JAVA实现账户取款和存款操作,⽂中通过⽰例代码介绍的⾮常详细,对⼤家的学习或者⼯作具有⼀定的参考学习价值,需要的朋友可以参考下JAVA 编写⼀个程序完成从某账户取款和存款的操作(1)输⼊存款⾦额是,如果⾮数值型,捕获⼀场并进⾏处理(2)操作账户类是,如果取款⾦额⼤于余额时则做异常处理import java.util.Scanner;public class Blank {public static void main(String[] args) {float residue = 10000.0f;String type;Scanner scn = new Scanner(System.in);while(true) {System.out.println("****当前账户余额:"+residue+"****");System.out.println("1.存钱 2.取钱 0.退出");System.out.print("请选择(1,2,0):");type = scn.nextLine();if(type.equals("1")) {System.out.print("请输⼊⾦额:");try {int money = scn.nextInt();residue = money+residue;} catch (Exception e) {// TODO: handle exceptionSystem.out.println("输⼊错误...");scn.nextLine();}}else if(type.equals("2")) {try {System.out.print("请输⼊:");int money = scn.nextInt();if(money>residue) {throw new Exception();} else {residue = residue-money;}} catch (Exception e) {// TODO: handle exceptionSystem.out.println("余额不⾜");scn.nextLine();}}else if(type.equals("0")) {System.out.println("bye..");break;}}}}以上就是本⽂的全部内容,希望对⼤家的学习有所帮助,也希望⼤家多多⽀持。

【继续】java项目ATM银行系统源代码

【继续】java项目ATM银行系统源代码

【关键字】继续//初始密码为123456import java.awt.*;import ;import javax.swing.*;public class MyATM extends JFrame implements ActionListener{JPanelpanelfirst,panelmain,panel3,panel4,panel5,panel6,panel7,panelchangepwd,panelchangepwded,pan elsave,panelsaved,panelremain,paneltrans,paneltransed,panelmobile,panelmobiled, panelconsult;JButtonbtn0,btn1,btn2,btn3,btn4,btn5,btn6,btn7,btn8,btn9,btn10,btnsure,btnback,btnok,btncard,btngetcard ,btnincard;JButtonbtn00,btn01,btn02,btn03,btn04,btn05,btn06,btn07,btn08,btn09,btn010,btnback1,btnremain,btnrem ain1,btnremain2;JButtonbtn000,btn001,btn002,btn003,btn004,btn005,btn006,btn007,btn008,btn009,btn100,btn200,btn300, btn1000,btn500,btnsure1,btnback2,btn0010,btnquok1,btnquok2,btnquok3,btnquok4;JButtonbtnpwd,btnpwd1,btnpwd2,btnpwd3,btnpwd4,btn11,btn12,btn13,btn14,btn15,btn16,btn17,btn18,bt n19,btn20,btnsave,btnsave1,btnsave2,btnsaved,btnsaved1,btnsaved2,btnsaved3;JButtonbtntra,btntra1,btntra2,btntraed,btntraed1,btn21,btn22,btn23,btn24,btn25,btn26,btn27,btn28,btn29,b tn30,btncon,btncon1;JButtonbtnmo,btnmo1,btnmo2,btnmo30,btnmo50,btnmo100,btnmo200,btnmo500,btnmo10,btnmo11,btn mo12,btnmo13,btnmo14,btnmo15,btnmo16,btnmo17,btnmo18,btnmo19,btnmoed,btnmoed1;JTextField txt2,txttrans,txttrans1,txttrans2,txtmo,txtmo1;JLabellbljixu,lblpwd,lblwrong,lblqukuan,lblquok1,lblquok2,lblpwd1,lblpwd2,lblpwd3,lblpwd4,lblsave,l blsave1,lblsaved,lblremain,lblremain1,lbltra,lbltra1,lbltra2,lbltraed,lbltraed1;JLabel lblwel,lblwel1,lblmo,lblmo1,lblmo2,lblmo3,lblmoed,lblmoed1,lblcon,lblcon1;JPasswordField txt1,txtpwd,txtpwd1;Container container;CardLayout Layout;int money,savemoney,mobilemoney=0;double lastmoney,trainsmoney;String userpwd,cardnum,trains,username;boolean flag=true,flag1=false,flag2=false,flag3=true,flag4=false,flag5=false;//构造方法public MyATM(){super("罗灿银行");this.setSize(435,350);this.setLocation(500, 250);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );//设置不可改变窗口大小this.setResizable(false);//设置程序小图标this.setIconImage(this.getToolkit().getImage("images\\haizei.jpg")); }//布局public void setLayout(){//用卡片布局Layout=new CardLayout();container=getContentPane();container.setLayout(Layout);//添加第一张卡片panelfirst=new JPanel(null);//设置卡片的背景颜色panelfirst.setBackground(new Color(119,119,253));lbljixu=new JLabel("请放入磁卡,然后继续操作");//设置卡片在Panel中的位置lbljixu.setBounds(140,90,350,30);//为第一张卡片添加一个Labelpanelfirst.add(lbljixu);//为第一张卡片添加一个按钮btncard=new JButton("继续");btncard.setBounds(310,180,80,30);//为按钮注册事件监听器btncard.addActionListener(this);//开始时设置按钮不可按btncard.setEnabled(false);panelfirst.add(btncard);//为第一张卡片添加一个按钮btngetcard=new JButton("取卡");btngetcard.setEnabled(false);btngetcard.setBounds(310,220,80,30);btngetcard.addActionListener(this);panelfirst.add(btngetcard);//为第一张卡片添加一个按钮btnincard=new JButton("插卡");btnincard.setBounds(40,220,80,30);btnincard.addActionListener(this);panelfirst.add(btnincard);container.add(panelfirst,"first");//添加登录输入密码卡片panelmain=new JPanel(null);panelmain.setBackground(new Color(119,119,253)); lblpwd=new JLabel("请输入您的银行卡密码:"); panelmain.add(lblpwd);lblpwd.setBounds(150, 20, 150, 30);//设置文本框为密码型txt1=new JPasswordField(12);//文本框不可选中txt1.enable(false);panelmain.add(txt1);//文本框的输入内容用*显示txt1.setEchoChar('*');txt1.setBounds(115,50,200,30);//添加选择按钮btnsure=new JButton("确定");btnsure.addActionListener(this);panelmain.add(btnsure);btnsure.setBounds(70,160,80,30);//添加重输按钮btn010=new JButton("重输");btn010.addActionListener(this);panelmain.add(btn010);btn010.setBounds(175,160,80,30);btnback=new JButton("退出");btnback.addActionListener(this);panelmain.add(btnback);btnback.setBounds(280,160,80,30);lblwrong=new JLabel("请注意保护好您的密码!"); panelmain.add(lblwrong);lblwrong.setBounds(150,90,200,30);//添加输入按钮btn01=new JButton("1");btn01.addActionListener(this);panelmain.add(btn01);btn01.setBounds(45,210,60,30);btn02=new JButton("2");btn02.addActionListener(this);panelmain.add(btn02);btn02.setBounds(115,210,60,30);btn03=new JButton("3");btn03.addActionListener(this);panelmain.add(btn03);btn03.setBounds(185,210,60,30);btn04=new JButton("4");btn04.addActionListener(this);panelmain.add(btn04);btn04.setBounds(255,210,60,30);btn05=new JButton("5");btn05.addActionListener(this);panelmain.add(btn05);btn05.setBounds(325,210,60,30);btn06=new JButton("6");btn06.addActionListener(this);panelmain.add(btn06);btn06.setBounds(45,260,60,30);btn07=new JButton("7");btn07.addActionListener(this);panelmain.add(btn07);btn07.setBounds(115,260,60,30);container.add(panelmain,"main");btn08=new JButton("8");btn08.addActionListener(this);panelmain.add(btn08);btn08.setBounds(185,260,60,30);btn09=new JButton("9");btn09.addActionListener(this);panelmain.add(btn09);btn09.setBounds(255,260,60,30);btn00=new JButton("0");btn00.addActionListener(this);panelmain.add(btn00);btn00.setBounds(325,260,60,30);//添加主界面卡片panel3=new JPanel(null);panel3.setBackground(new Color(119,119,253));lblwel=new JLabel(username+",欢迎使用罗灿银行ATM系统"); lblwel.setBounds(20,15,350,30);panel3.add(lblwel);lblwel1=new JLabel("请选择您需要的交易类型");lblwel1.setBounds(220,55,350,30);panel3.add(lblwel1);btn3=new JButton("取款服务");btn3.addActionListener(this);btn3.setBounds(20,90,100,30);panel3.add(btn3);btn4=new JButton("修改密码");btn4.addActionListener(this);btn4.setBounds(20,150,100,30);panel3.add(btn4);btn5=new JButton("存款服务");btn5.addActionListener(this);btn5.setBounds(20,210,100,30);panel3.add(btn5);btn6=new JButton("查询余额");btn6.addActionListener(this);btn6.setBounds(20,270,100,30);panel3.add(btn6);btn7=new JButton("转账服务");btn7.addActionListener(this);btn7.setBounds(300,90,100,30);panel3.add(btn7);btn8=new JButton("通信交费");btn8.addActionListener(this);btn8.setBounds(300,150,100,30);panel3.add(btn8);btn9=new JButton("咨询服务");btn9.addActionListener(this);btn9.setBounds(300,210,100,30);panel3.add(btn9);btn10=new JButton("退出操作");btn10.addActionListener(this);btn10.setBounds(300,270,100,30);panel3.add(btn10);container.add(panel3,"three");//添加取款页面卡片panel4=new JPanel(null);panel4.setBackground(new Color(119,119,253));lblqukuan=new JLabel("请输入您的取款数:");panel4.add(lblqukuan);lblqukuan.setBounds(115, 20, 150, 30);lblqukuan=new JLabel("提示:只能是100元或100元的整数倍。

Java-银行管理系统源代码

Java-银行管理系统源代码

Java 小型银行管理系统源代码(图形界面)accounts.javapackage Account;public class accounts {protected int id;// 银行账号protected String password;// 用户密码protected String name;// 用户型号protected String personId;// 身份账号protected int accountType;// 账号类型,0 代表储蓄卡, 1 代表信用卡protected double balance;// 账户余额。

之所以定义为protected 是让他的子类可以直接用,不需要通过方法来赋值。

protected double ceiling;public String getPassword(){return password;}public void setPassword(String password){this.password=password;}public String getName(){return name;}public void setName(String name){=name;}public String getPersonId(){return personId;}public void setPersonId(String personId){this.personId=personId;}public int getAccountType(){return accountType;}public void setAccountType(int accountType){this.accountType=accountType;}public double getBalance(){return balance;}public void setBalance(double balance){this.balance=balance;}public int getId(){return id;}public void setId(int id){this.id=id;}public double getCeiling(){return ceiling;}public void setCeiling(double ceiling){this.ceiling=ceiling;}// 无参数构造方法public accounts(){}// 构造方法public accounts(String password,String name,String personId,int accountType, double balance,double ceiling){super();this.password=password;=name;this.personId=personId;this.accountType=accountType;this.balance=balance;this.ceiling=ceiling;}// 存款public void deposit(double money){balance+=money;}// 取款public void withdraw(double money){if(accountType==1){if((balance+ceiling)<money){System.out.println(" 对不起,已超出您的信用额度!");}else{balance-=money;}}else{if(balance<money){System.out.println(" 对不起,账户余额不足!");}else{balance-=money;}}}}DBoper.javapackage DB;import java.sql.*;import java.util.ArrayList;import Account.accounts;public class DBoper {private Connection conn = null;private Statement st = null;private PreparedStatement pstmt = null;private ResultSet rs = null;private ArrayList<accounts> result;// 连接数据库public Connection getConnection(){try{Class.forName("com.mysql.jdbc.Driver");conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/bankmanager?useUnicode=true&characterEncoding=utf8","root","xuewei");}catch(Exception e){System.out.println(" 数据库连接失败");}return conn;}// 修改删除用户数据public boolean accountDataUpdate(String sql){conn=getConnection();try{pstmt=conn.prepareStatement(sql);pstmt.executeUpdate();//System.out.println(" 数据更新成功");conn.close();return true;}catch(SQLException e){e.printStackTrace();//System.out.println(" 更新失败");return false;}}// 依据id 来修改记录public boolean dataupdateid(accounts user, int id) {conn = getConnection();try {String sql = "update account set username=?,userpwd=?,personId=?,accountType=?,balance=?,ceiling=? where id="+ id;pstmt = conn.prepareStatement(sql);pstmt.setString(1, user.getName());pstmt.setString(2, user.getPassword());pstmt.setString(3, user.getPersonId());pstmt.setInt(4, user.getAccountType());pstmt.setDouble(5, user.getBalance());pstmt.setDouble(6, user.getCeiling());pstmt.executeUpdate();System.out.println(" 操作成功");return true;}catch (SQLException e) {e.printStackTrace();System.out.println(" 操作失败");return false;}}// 插入用户数据public boolean accountDataInsert(accounts account){conn=getConnection();try{pstmt=conn.prepareStatement("insert into account (username,userpwd,personId,accountType,balance,ceiling) values (?,?,?,?,?,?)");pstmt.setString(1, account.getName());pstmt.setString(2, account.getPassword());pstmt.setString(3, account.getPersonId());pstmt.setInt(4, account.getAccountType());pstmt.setDouble(5, account.getBalance());pstmt.setDouble(6, account.getCeiling());pstmt.executeUpdate();System.out.println(" 新用户数据插入成功");conn.close();return true;}catch(SQLException e){e.printStackTrace();System.out.println(" 插入失败");return false;}}// 查询数据public ResultSet dataquery(String sql) {conn = getConnection();try {pstmt = conn.prepareStatement(sql);rs = pstmt.executeQuery();}catch (SQLException e) {e.printStackTrace();System.out.println(" 检索失败");}return rs;}public ResultSet testlist() {try {String sql = "select * from account where id =1001";pstmt = conn.prepareStatement(sql);System.out.println(sql);rs = pstmt.executeQuery();} catch (SQLException e) {e.printStackTrace();System.out.println(" 检索失败");}return rs;}public ArrayList<accounts> testt(int id) {ArrayList<accounts> list = new ArrayList<accounts>();conn = getConnection();try {String sql = "select * from account where id=" + id;pstmt = conn.prepareStatement(sql);rs = pstmt.executeQuery();while (rs.next()) {accounts user = new accounts();user.setName(rs.getString("username"));user.setPassword(rs.getString("userpwd"));user.setPersonId(rs.getString("personId"));user.setAccountType(rs.getInt("accountType"));user.setBalance(rs.getDouble("balance"));user.setCeiling(rs.getDouble("ceiling"));list.add(user);}}catch (SQLException e) {e.printStackTrace();System.out.println(" 检索失败");}return list;}// 根据卡号和密码验证用户是否存在public boolean verify(int id,String password){conn=getConnection();try{pstmt=conn.prepareStatement("select * from account where id=? and userpwd=?");pstmt.setInt(1, id);pstmt.setString(2, password);rs=pstmt.executeQuery();if(rs.next()){return true;}else{return false;}}catch(SQLException e){e.printStackTrace();return false;}}/*** 登录验证*/public accounts verifyAccount(int id, String password) {boolean flag = verify(id, password);if(flag){accounts account=queryByIDandPassword(id, password);return account;}else{System.out.println(" 用户不存在!");return null;}}// 根据卡号和密码查询信息public accounts queryByIDandPassword(int id,String password){conn=getConnection();try{pstmt=conn.prepareStatement("select * from account where id=? and userpwd=?");pstmt.setInt(1, id);pstmt.setString(2, password);rs=pstmt.executeQuery();accounts account=new accounts();while(rs.next()){account.setId(rs.getInt("id"));account.setName(rs.getString("username"));account.setPassword(rs.getString("userpwd"));account.setPersonId(rs.getString("personId"));account.setAccountType(rs.getInt("accountType"));account.setBalance(rs.getDouble("balance"));account.setCeiling(rs.getDouble("ceiling"));}return account;}catch(SQLException e){e.printStackTrace();return null;}}// 根据卡号查询信息public accounts queryByID(int id){conn=getConnection();try{pstmt=conn.prepareStatement("select * from account where id=?");pstmt.setInt(1, id);rs=pstmt.executeQuery();accounts account=new accounts();while(rs.next()){account.setId(rs.getInt("id"));account.setName(rs.getString("username"));account.setPassword(rs.getString("userpwd"));account.setPersonId(rs.getString("personId"));account.setAccountType(rs.getInt("accountType"));account.setBalance(rs.getDouble("balance"));account.setCeiling(rs.getDouble("ceiling"));}return account;}catch(SQLException e){e.printStackTrace();return null;}}public static void main(String[] args) {// TODO Auto-generated method stubDBoper op=new DBoper();ArrayList<accounts> list=op.testt(1001);for(int i=0;i<list.size();i++){accounts user=new accounts();user=list.get(i);System.out.println(user.getName());System.out.println(user.getPassword());System.out.println(user.getPersonId());System.out.println(user.getAccountType());System.out.println(user.getBalance());System.out.println(user.getCeiling());}}}// 图像界面文件夹DN_SYSTEMDefault.java // 主界面package DN_SYSTEM;import java.awt.Color;import java.awt.Container;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.WindowConstants;import Account.accounts;import DB.DBoper;public class Default extends JFrame implements ActionListener{accounts account=DN_ATM.client;DBoper db=new DBoper();private JFrame jf;private JButton btn0,btn1,btn2,btn3,btn4,btn5;private Container c;public void defaltDemo() {// 添加主界面卡片//DN_ATM.id;int id=DN_ATM.id;//account=db.queryByID(id);jf=new JFrame("DEFAULT");c=jf.getContentPane();c.setLayout(null);c.setBackground(new Color(119,119,253));JLabel lblwel = new JLabel("欢迎"+account.getName()+" 用达能银行ATM系统");lblwel.setBounds(20, 15, 350, 30);c.add(lblwel);JLabel lblwel1 = new JLabel("请选择您需要的交易类型");lblwel1.setBounds(120, 45, 350, 30);c.add(lblwel1);btn1 = new JButton(" 取款服务");btn1.addActionListener(this);btn1.setBounds(70, 90, 100, 30);c.add(btn1);btn2=new JButton(" 存款服务");btn2.addActionListener(this);btn2.setBounds(210, 90, 100, 30);c.add(btn2);btn3 = new JButton(" 查询余额");btn3.addActionListener(this);btn3.setBounds(70, 150, 100, 30);c.add(btn3);btn4 = new JButton(" 转账服务");btn4.addActionListener(this);btn4.setBounds(210, 150, 100, 30);c.add(btn4);btn5 = new JButton(" 注销账户");btn5.addActionListener(this);btn5.setBounds(70, 210, 100, 30);c.add(btn5);btn0 = new JButton(" 退出操作");btn0.addActionListener(this);btn0.setBounds(210, 210, 100, 30);c.add(btn0);jf.setVisible(true);jf.setResizable(false);jf.setSize(400,300);jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); }// 事件处理@Overridepublic void actionPerformed(ActionEvent e){// 取款服务if(e.getSource().equals(btn1)){OutMoney outmoney=new OutMoney();outmoney.outMoney();jf.dispose();}// 存款服务if(e.getSource().equals(btn2)){InMoney inmoney=new InMoney();inmoney.InMoney();jf.dispose();}// 查询余额if(e.getSource().equals(btn3)){GetBalance getbalance=new GetBalance();getbalance.getBalance();jf.dispose();}// 转账服务if(e.getSource().equals(btn4)){TransferAccounts tranfer=new TransferAccounts();tranfer.transferAccounts();jf.dispose();}// 注销账户if(e.getSource().equals(btn5)){String sql="delete from account where id="+account.getId();boolean flag=db.accountDataUpdate(sql);if(flag){JOptionPane.showMessageDialog(this," 注销成功!");}else{JOptionPane.showMessageDialog(this, " 注销失败!");}}if(e.getSource().equals(btn0)){System.exit(0);}}public static void main(String[] args) {// TODO Auto-generated method stubDefault defaults=new Default();defaults.defaltDemo();}}DN_ATM.java // 功能界面package DN_SYSTEM;import java.awt.CardLayout;import java.awt.Color;import java.awt.Container;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.AbstractButton;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JTextField;import DB.DBoper;import Account.accounts;public class DN_ATM extends JFrame implements ActionListener{ private JLabel lbljixu;private JButton btngetcard;private JButton btncard,btn010,btn_addAccount,btnsure,btnback;private JTextField txt1;private JPasswordField txt2;private Container container;private CardLayout Layout;private JLabel lblwrong;private JPanel panelfirst,panelmain;public static int id;static accounts client = null;public DN_ATM(){super("达能银行");this.setSize(435, 350);this.setLocation(500,250);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);// 设置不可改变窗口大小this.setResizable(false);}// 布局public void setLayout(){// 用卡片布局Layout = new CardLayout();container = getContentPane();container.setLayout(Layout);// 添加第一张卡片panelfirst = new JPanel(null);// 设置卡片的背景颜色panelfirst.setBackground(new Color(119,119,253));lbljixu = new JLabel(" 请放入磁卡,然后继续操作");// 设置卡片在Panel 中的位置lbljixu.setBounds(140, 90, 350, 30);// 为第一张卡片添加一个Labelpanelfirst.add(lbljixu);// 为第一张卡片添加一个按钮btncard = new JButton(" 继续");btncard.setBounds(310, 180, 80, 30);// 为按钮注册事件监听器btncard.addActionListener(this);// 开始时设置按钮不可按btncard.setEnabled(false);panelfirst.add(btncard);// 为第一张卡片添加一个按钮btngetcard = new JButton(" 取卡");btngetcard.setEnabled(false);btngetcard.setBounds(310, 220, 80, 30);btngetcard.addActionListener(this);panelfirst.add(btngetcard);// 添加登录输入卡片panelmain = new JPanel(null);panelmain.setBackground(new Color(119,119,253));// 添加登录输入卡号JLabel lblnumber = new JLabel("请输入您的银行卡卡号:"); panelmain.add(lblnumber);lblnumber.setBounds(30, 30, 150, 30);// 设置文本框为密码型txt1 = new JTextField(12);// 文本框不可选中//txt1.enable(false);panelmain.add(txt1);txt1.setBounds(170, 30, 200, 30);JLabel lblpwd = new JLabel("请输入您的银行卡密码:"); panelmain.add(lblpwd);lblpwd.setBounds(30, 80, 150, 30);// 设置文本框为密码型txt2 = new JPasswordField(12);// 文本框不可选中//txt2.enable(false);panelmain.add(txt2);// 文本框的输入内容用* 显示txt2.setEchoChar('*');txt2.setBounds(170, 80, 200, 30);// 添加选择按钮btnsure = new JButton(" 确定");btnsure.addActionListener(this);panelmain.add(btnsure);btnsure.setBounds(70, 160, 80, 30);// 添加重输按钮btn010 = new JButton(" 重输");btn010.addActionListener(this);panelmain.add(btn010);btn010.setBounds(175,160,80,30);btnback = new JButton(" 退出");btnback.addActionListener(this);panelmain.add(btnback);btnback.setBounds(280, 160, 80, 30);// 开户btn_addAccount = new JButton(" 开户");btn_addAccount.setBounds(70, 220, 80, 30);btn_addAccount.addActionListener(this);panelmain.add(btn_addAccount);lblwrong = new JLabel(" 请注意保护好您的密码!");panelmain.add(lblwrong);lblwrong.setBounds(180, 110, 200, 30);container.add(panelmain, "main");}// 事件处理@SuppressWarnings("deprecation")@Overridepublic void actionPerformed(ActionEvent e){DBoper db=new DBoper();if(e.getSource().equals(btn_addAccount)){OpenAccount open=new OpenAccount();open.adduser();}// 磁卡插入后,验证银行登录卡号与密码if(e.getSource().equals(btnsure)){client = db.verifyAccount(Integer.parseInt(txt1.getText()), txt2.getText());if(client!=null){Default defa=new Default();defa.defaltDemo();this.dispose();id=Integer.parseInt(txt1.getText());txt1.setText("");txt2.setText("");}else{lblwrong.setText(" 卡号或密码不正确,请重新输入!");txt1.setText("");txt2.setText("");}}// 重置输入卡号和密码if(e.getSource()==btn010){txt1.setText("");txt2.setText("");lblwrong.setText(" 请注意保护好您的密码!");}// 退出if(e.getSource().equals(btnback)){System.exit(0);}}public static void main(String[] args) {// TODO Auto-generated method stubDN_ATM ATM=new DN_ATM();ATM.setLayout();ATM.setVisible(true);}}GetBalance.java // 查询余额package DN_SYSTEM;import java.awt.CardLayout;import java.awt.Color;import java.awt.Container;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.WindowConstants;import Account.accounts;import DB.DBoper;public class GetBalance extends JFrame implements ActionListener{ private JFrame jf;private Container c;private JLabel lblremain1,lblremain;private JButton btnremain,btnremain1;accounts account=new accounts();DBoper db=new DBoper();private int id=DN_ATM.id;// 添加查询余额界面卡片public void getBalance(){account=db.queryByID(id);jf=new JFrame("FIND DALANCE");c=jf.getContentPane();c.setLayout(null);jf.setResizable(false);c.setBackground(new Color(119,119,253));lblremain1 = new JLabel(" 尊敬的达能用户您好!");lblremain1.setBounds(90,70,350,30);c.add(lblremain1);lblremain = new JLabel(" 请点击继续操作查询余额:");lblremain.setBounds(90,110,350,30);c.add(lblremain);btnremain = new JButton(" 继续操作");btnremain.setBounds(95,150,90,30);btnremain.addActionListener(this);c.add(btnremain);btnremain1 = new JButton(" 退出操作");btnremain1.setBounds(200,150,90,30);btnremain1.addActionListener(this);c.add(btnremain1);jf.setVisible(true);jf.setSize(400,300);jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);}@Overridepublic void actionPerformed(ActionEvent e){// 查询余额if(e.getSource()==btnremain){lblremain1.setText(" 卡号:"+account.getId()+" 用户名:"+account.getName());lblremain.setText(" 您的余额为"+account.getBalance()+" 元,是否继续操作?");}if(e.getSource()==btnremain1){Default defa=new Default();defa.defaltDemo();jf.dispose();}}public static void main(String[] args) {// TODO Auto-generated method stubGetBalance balance=new GetBalance();balance.getBalance();}}InMoney.java // 存款package DN_SYSTEM;import java.awt.CardLayout;import java.awt.Color;import java.awt.Container;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JTextField;import javax.swing.WindowConstants;import Account.accounts;import DB.DBoper;public class InMoney extends JFrame implements ActionListener{private JLabel lblsave,lblsave1;private JButton btnsave,btnsave2;private JTextField txt2;private double savemoney ;private double lastmoney;private boolean flag;private JFrame jf;private Container c;accounts account=new accounts();DBoper db=new DBoper();private int id=DN_ATM.id;public void InMoney(){account=db.queryByID(id);jf=new JFrame("IN MONEY");c=jf.getContentPane();c.setLayout(null);jf.setResizable(false);// 添加存款显示界面卡片c.setBackground(new Color(119,119,253));lblsave = new JLabel("请在存款口处放入存款");lblsave.setBounds(60,30,350,30);c.add(lblsave);lblsave1 = new JLabel("请注意:只接收100 元或100 元的整数倍存款");lblsave1.setBounds(90,110,350,30);c.add(lblsave1);txt2 = new JTextField(12);c.add(txt2);txt2.setBounds(95, 80, 200, 30);btnsave = new JButton(" 放入存款完毕");btnsave.setBounds(90,160,120,30);btnsave.addActionListener(this);c.add(btnsave);btnsave2 = new JButton(" 返回");btnsave2.setBounds(240,160,60,30);btnsave2.addActionListener(this);c.add(btnsave2);jf.setVisible(true);jf.setSize(400,300);jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);}@Overridepublic void actionPerformed(ActionEvent e){if(e.getSource()==btnsave){savemoney=Double.parseDouble(txt2.getText());lastmoney=account.getBalance();lastmoney+=savemoney;String sql = "update account set balance="+lastmoney+"where id="+ id;flag=db.accountDataUpdate(sql);if(flag){JOptionPane.showMessageDialog(this, " 存款成功!");txt2.setText("");Default defa=new Default();defa.defaltDemo();jf.dispose();}else{JOptionPane.showMessageDialog(this, " 存款失败!");}}if(e.getSource()==btnsave2){Default defa=new Default();defa.defaltDemo();jf.dispose();}}public static void main(String[] args) {// TODO Auto-generated method stubInMoney inmoney=new InMoney();inmoney.InMoney();}}OpenAccount.java // 开户package DN_SYSTEM;import ponent;import java.awt.Container;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.ButtonGroup;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPasswordField;import javax.swing.JRadioButton;import javax.swing.JTextField;import javax.swing.WindowConstants;import DB.DBoper;import Account.accounts;public class OpenAccount extends JFrame implements ActionListener{private JFrame jf;private Container c;private JTextField txtname,txt_personId;private JPasswordField txtpwd,txtpwd1;private JRadioButton rbt1;private JRadioButton rbt2;String accountType;// 开户,增加新用户public void adduser(){jf=new JFrame("Open Account");c=jf.getContentPane();c.setLayout(null);jf.setResizable(false);JLabel lbname=new JLabel("用户名:");lbname.setBounds(100, 40, 80, 20);txtname=new JTextField();txtname.setBounds(160, 40, 130, 20);c.add(lbname);c.add(txtname);JLabel lbpwd=new JLabel("密码:");lbpwd.setBounds(110, 65, 80, 20);txtpwd=new JPasswordField();txtpwd.setBounds(160, 65, 130, 20);txtpwd.setEchoChar('*');c.add(lbpwd);c.add(txtpwd);JLabel lbpwd1=new JLabel("确认密码:");lbpwd1.setBounds(86, 90, 80, 20);txtpwd1 = new JPasswordField();txtpwd1.setBounds(160, 90, 130, 20);txtpwd1.setEchoChar('*');c.add(lbpwd1);c.add(txtpwd1);JLabel lbpersonId=new JLabel("身份证号:");lbpersonId.setBounds(86, 115, 80, 20);txt_personId = new JTextField();txt_personId.setBounds(160, 115, 130, 20);c.add(lbpersonId);c.add(txt_personId);JLabel lbtype=new JLabel("账户类型:");lbtype.setBounds(86, 120, 80, 60);rbt1=new JRadioButton(" 信用卡");rbt1.setBounds(160, 135, 70, 30);rbt2=new JRadioButton(" 储蓄卡");rbt2.setBounds(225, 135, 70, 30);ButtonGroup group=new ButtonGroup();group.add(rbt2);group.add(rbt1);c.add(lbtype);c.add(rbt2);c.add(rbt1);JButton btnsubmit=new JButton(" 提交");btnsubmit.setBounds(100, 190, 80, 20);JButton btnreset=new JButton(" 重置");btnreset.setBounds(205, 190, 80, 20);c.add(btnsubmit);c.add(btnreset);btnsubmit.addActionListener(this);btnreset.addActionListener(this);jf.setVisible(true);jf.setSize(400,300);jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); }public static void main(String[] args) {// TODO Auto-generated method stubOpenAccount openA=new OpenAccount();openA.adduser();}@Overridepublic void actionPerformed(ActionEvent e){accounts account=new accounts();account.setName(txtname.getText());if(txtpwd.getText().equals(txtpwd1.getText())){account.setPassword(txtpwd.getText());}else{JOptionPane.showMessageDialog(this," 两次输入的密码不一致,请重新输入!");}account.setPersonId(txt_personId.getText());if(rbt1.isSelected())accountType="1";if(rbt2.isSelected())accountType="0";account.setAccountType(Integer.parseInt(accountType));account.setBalance(0);if(accountType.equals("1")){account.setCeiling(5000.0);}else{account.setCeiling(0);}DBoper db=new DBoper();if(db.accountDataInsert(account)){JOptionPane.showMessageDialog(this," 开户成功!");jf.dispose();// 关闭当前登录窗体return;}else{JOptionPane.showMessageDialog(this," 开户失败!");return;}}}OutMoney.java // 取款package DN_SYSTEM;import java.awt.CardLayout;import java.awt.Color;import java.awt.Container;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;import javax.swing.WindowConstants;import Account.accounts;import DB.DBoper;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;public class OutMoney extends JFrame implements ActionListener{private JFrame jf;private JButton btn100,btn200,btn300,btn500,btn1000;private JButton btn001,btn002,btn003,btn004,btn005,btn006,btn007,btn008,btn009,btn000;private JButton btnsure1,btn0010,btnback2;private JTextField txt2;private Container c;private JLabel lblqukuan;private int money;private double lastmoney;accounts account=new accounts();DBoper db=new DBoper();private int id=DN_ATM.id;public void outMoney(){account=db.queryByID(id);jf=new JFrame("OUT MONEY");c=jf.getContentPane();c.setLayout(null);jf.setResizable(false);// 添加取款页面卡片//panel4=new JPanel(null);c.setBackground(new Color(119,119,253));lblqukuan = new JLabel(" 请输入您的取款金额:");c.add(lblqukuan);lblqukuan.setBounds(115, 20, 150, 30);lblqukuan=new JLabel(" 提示:只能是100 元或100 元的整数倍");c.add(lblqukuan);lblqukuan.setBounds(115, 50, 300, 30);txt2 = new JTextField(12);txt2.enable(false);c.add(txt2);txt2.setBounds(115, 90, 200, 30);btn100 = new JButton("100");c.add(btn100);btn100.addActionListener(this);btn100.setBounds(45, 190, 60, 30);btn200 = new JButton("200");c.add(btn200);btn200.addActionListener(this);btn200.setBounds(115, 190, 60, 30);btn300 = new JButton("300");c.add(btn300);btn300.addActionListener(this);btn300.setBounds(185, 190, 60, 30);btn500 = new JButton("500");btn500=new JButton("500");c.add(btn500);btn500.addActionListener(this);btn500.setBounds(255, 190, 60, 30);btn1000 = new JButton("1000");c.add(btn1000);btn1000.addActionListener(this);btn1000.setBounds(325, 190, 65, 30);btn001 = new JButton("1");c.add(btn001);btn001.addActionListener(this);btn001.setBounds(45, 230, 60, 30);btn002 = new JButton("2");c.add(btn002);btn002.addActionListener(this); btn002.setBounds(115, 230, 60, 30);btn003 = new JButton("3");c.add(btn003);btn003.addActionListener(this); btn003.setBounds(185, 230, 60, 30);btn004 = new JButton("4");c.add(btn004);btn004.addActionListener(this); btn004.setBounds(255, 230, 60, 30);btn005 = new JButton("5");c.add(btn005);btn005.addActionListener(this); btn005.setBounds(325, 230, 65, 30);btn006 = new JButton("6");c.add(btn006);btn006.addActionListener(this); btn006.setBounds(45, 270, 60, 30);btn007 = new JButton("7");c.add(btn007);btn007.addActionListener(this); btn007.setBounds(115, 270, 60, 30);btn008 = new JButton("8");c.add(btn008);btn008.addActionListener(this); btn008.setBounds(185, 270, 60, 30);btn009 = new JButton("9");c.add(btn009);btn009.addActionListener(this); btn009.setBounds(255, 270, 60, 30);btn000 = new JButton("0");c.add(btn000);btn000.addActionListener(this); btn000.setBounds(325, 270, 65, 30);btnsure1 = new JButton(" 确定");。

java项目 ATM银行系统 源代码

java项目 ATM银行系统 源代码

//初始密码为123456import java.awt.*;import java.awt.event.*;import javax.swing.*;public class MyATM extends JFrame implements ActionListener{ JPanelpanelfirst,panelmain,panel3,panel4,panel5,panel6,panel7,panelchangepw d,panelchangepwded,panelsave,panelsaved,panelremain,paneltrans,panelt ransed,panelmobile,panelmobiled,panelconsult;JButtonbtn0,btn1,btn2,btn3,btn4,btn5,btn6,btn7,btn8,btn9,btn10,btnsure,btnba ck,btnok,btncard,btngetcard,btnincard;JButtonbtn00,btn01,btn02,btn03,btn04,btn05,btn06,btn07,btn08,btn09,btn010,bt nback1,btnremain,btnremain1,btnremain2;JButtonbtn000,btn001,btn002,btn003,btn004,btn005,btn006,btn007,btn008,btn009 ,btn100,btn200,btn300,btn1000,btn500,btnsure1,btnback2,btn0010,btnquo k1,btnquok2,btnquok3,btnquok4;JButtonbtnpwd,btnpwd1,btnpwd2,btnpwd3,btnpwd4,btn11,btn12,btn13,btn14,btn15, btn16,btn17,btn18,btn19,btn20,btnsave,btnsave1,btnsave2,btnsaved,btns aved1,btnsaved2,btnsaved3;JButtonbtntra,btntra1,btntra2,btntraed,btntraed1,btn21,btn22,btn23,btn24,btn 25,btn26,btn27,btn28,btn29,btn30,btncon,btncon1;JButtonbtnmo,btnmo1,btnmo2,btnmo30,btnmo50,btnmo100,btnmo200,btnmo500,btnmo1 0,btnmo11,btnmo12,btnmo13,btnmo14,btnmo15,btnmo16,btnmo17,btnmo18,btn mo19,btnmoed,btnmoed1;JTextField txt2,txttrans,txttrans1,txttrans2,txtmo,txtmo1;JLabellbljixu,lblpwd,lblwrong,lblqukuan,lblquok1,lblquok2,lblpwd1,lblpwd2,l blpwd3,lblpwd4,lblsave,lblsave1,lblsaved,lblremain,lblremain1,lbltra, lbltra1,lbltra2,lbltraed,lbltraed1;JLabellblwel,lblwel1,lblmo,lblmo1,lblmo2,lblmo3,lblmoed,lblmoed1,lblcon,lbl con1;JPasswordField txt1,txtpwd,txtpwd1;Container container;CardLayout Layout;int money,savemoney,mobilemoney=0;double lastmoney,trainsmoney;String userpwd,cardnum,trains,username;booleanflag=true,flag1=false,flag2=false,flag3=true,flag4=false,flag5=false;//构造方法public MyATM(){super("罗灿银行");this.setSize(435,350);this.setLocation(500, 250);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );//设置不可改变窗口大小this.setResizable(false);//设置程序小图标this.setIconImage(this.getToolkit().getImage("images\\haizei.jpg" ));}//布局public void setLayout(){//用卡片布局Layout=new CardLayout();container=getContentPane();container.setLayout(Layout);//添加第一张卡片panelfirst=new JPanel(null);//设置卡片的背景颜色panelfirst.setBackground(new Color(119,119,253));lbljixu=new JLabel("请放入磁卡,然后继续操作");//设置卡片在Panel中的位置lbljixu.setBounds(140,90,350,30);//为第一张卡片添加一个Labelpanelfirst.add(lbljixu);//为第一张卡片添加一个按钮btncard=new JButton("继续");btncard.setBounds(310,180,80,30);//为按钮注册事件监听器btncard.addActionListener(this);//开始时设置按钮不可按btncard.setEnabled(false);panelfirst.add(btncard);//为第一张卡片添加一个按钮btngetcard=new JButton("取卡");btngetcard.setEnabled(false);btngetcard.setBounds(310,220,80,30);btngetcard.addActionListener(this);panelfirst.add(btngetcard);//为第一张卡片添加一个按钮btnincard=new JButton("插卡");btnincard.setBounds(40,220,80,30);btnincard.addActionListener(this);panelfirst.add(btnincard);container.add(panelfirst,"first");//添加登录输入密码卡片panelmain=new JPanel(null);panelmain.setBackground(new Color(119,119,253)); lblpwd=new JLabel("请输入您的银行卡密码:"); panelmain.add(lblpwd);lblpwd.setBounds(150, 20, 150, 30);//设置文本框为密码型txt1=new JPasswordField(12);//文本框不可选中txt1.enable(false);panelmain.add(txt1);//文本框的输入内容用*显示txt1.setEchoChar('*');txt1.setBounds(115,50,200,30);//添加选择按钮btnsure=new JButton("确定");btnsure.addActionListener(this);panelmain.add(btnsure);btnsure.setBounds(70,160,80,30);//添加重输按钮btn010=new JButton("重输");btn010.addActionListener(this);panelmain.add(btn010);btn010.setBounds(175,160,80,30);btnback=new JButton("退出");btnback.addActionListener(this); panelmain.add(btnback);btnback.setBounds(280,160,80,30);lblwrong=new JLabel("请注意保护好您的密码!"); panelmain.add(lblwrong);lblwrong.setBounds(150,90,200,30);//添加输入按钮btn01=new JButton("1");btn01.addActionListener(this);panelmain.add(btn01);btn01.setBounds(45,210,60,30);btn02=new JButton("2");btn02.addActionListener(this);panelmain.add(btn02);btn02.setBounds(115,210,60,30);btn03=new JButton("3");btn03.addActionListener(this);panelmain.add(btn03);btn03.setBounds(185,210,60,30);btn04=new JButton("4");btn04.addActionListener(this);panelmain.add(btn04);btn04.setBounds(255,210,60,30);btn05=new JButton("5");btn05.addActionListener(this);panelmain.add(btn05);btn05.setBounds(325,210,60,30);btn06=new JButton("6");btn06.addActionListener(this);panelmain.add(btn06);btn06.setBounds(45,260,60,30);btn07=new JButton("7");btn07.addActionListener(this);panelmain.add(btn07);btn07.setBounds(115,260,60,30);container.add(panelmain,"main");btn08=new JButton("8");btn08.addActionListener(this);panelmain.add(btn08);btn08.setBounds(185,260,60,30);btn09=new JButton("9");btn09.addActionListener(this);panelmain.add(btn09);btn09.setBounds(255,260,60,30);btn00=new JButton("0");btn00.addActionListener(this);panelmain.add(btn00);btn00.setBounds(325,260,60,30);//添加主界面卡片panel3=new JPanel(null);panel3.setBackground(new Color(119,119,253));lblwel=new JLabel(username+",欢迎使用罗灿银行ATM系统"); lblwel.setBounds(20,15,350,30);panel3.add(lblwel);lblwel1=new JLabel("请选择您需要的交易类型");lblwel1.setBounds(220,55,350,30);panel3.add(lblwel1);btn3=new JButton("取款服务");btn3.addActionListener(this);btn3.setBounds(20,90,100,30);panel3.add(btn3);btn4=new JButton("修改密码");btn4.addActionListener(this);btn4.setBounds(20,150,100,30);panel3.add(btn4);btn5=new JButton("存款服务");btn5.addActionListener(this);btn5.setBounds(20,210,100,30);panel3.add(btn5);btn6=new JButton("查询余额");btn6.addActionListener(this);btn6.setBounds(20,270,100,30);panel3.add(btn6);btn7=new JButton("转账服务");btn7.addActionListener(this);btn7.setBounds(300,90,100,30);panel3.add(btn7);btn8=new JButton("通信交费");btn8.addActionListener(this);btn8.setBounds(300,150,100,30);panel3.add(btn8);btn9=new JButton("咨询服务");btn9.addActionListener(this);btn9.setBounds(300,210,100,30);panel3.add(btn9);btn10=new JButton("退出操作");btn10.addActionListener(this);btn10.setBounds(300,270,100,30);panel3.add(btn10);container.add(panel3,"three");//添加取款页面卡片panel4=new JPanel(null);panel4.setBackground(new Color(119,119,253));lblqukuan=new JLabel("请输入您的取款数:");panel4.add(lblqukuan);lblqukuan.setBounds(115, 20, 150, 30);lblqukuan=new JLabel("提示:只能是100元或100元的整数倍。

周周复利法指标源码

周周复利法指标源码

周周复利法指标源码【原创实用版】目录1.周周复利法简介2.指标源码概述3.周周复利法的计算方法4.指标源码的实现5.周周复利法的应用案例6.总结正文1.周周复利法简介周周复利法是一种计算复利收益的方法,与传统的年复利法不同,周周复利法以每周为计息周期,从而更能反映实际的投资收益情况。

这种计息方式在投资领域被广泛应用,尤其对于短期投资和定期存款等具有较高的参考价值。

2.指标源码概述指标源码是指周周复利法的计算公式以及相关的代码实现。

通过对周周复利法的研究,可以更好地理解复利计息的原理,同时也可以为投资者提供更加精确的投资决策依据。

3.周周复利法的计算方法周周复利法的计算方法相对简单,其基本公式为:A = P(1 +r/52)^(52*t),其中A代表未来的投资收益,P代表本金,r代表年化收益率,t代表投资期限(以周为单位)。

通过这个公式,可以计算出每周的收益情况,从而更加准确地反映投资收益。

4.指标源码的实现为了方便投资者使用周周复利法,可以编写一段源代码来实现这个计算过程。

这段源代码可以采用任何编程语言编写,如 Python、Java 等。

在实际应用中,投资者只需输入本金、年化收益率和投资期限,源代码即可自动计算出每周的收益情况。

5.周周复利法的应用案例举个例子,假设投资者有 10000 元本金,年化收益率为 2%,投资期限为 1 年。

按照传统的年复利法计算,一年的收益为10000*(1+2%)=10200 元。

然而,按照周周复利法计算,每周的收益为10000*(1+2%/52)^(52*52)-10000≈10183.52 元。

可见,周周复利法更能反映实际的投资收益情况。

6.总结周周复利法是一种更加精确的复利计息方法,通过编写指标源码,可以方便地实现这个计算过程。

最新存款利息计算器源码程序

最新存款利息计算器源码程序

上传一个个人存款利息计算器的jsp源代码,经过调试可以正常使用了,php的空间即可。

界面如下,网络预览百度搜索。

尊重知识版权,请勿随便转载,请注明出处。

附录2 个人存款计算器 jsp源代码<%@page language="java"pageEncoding="GBK"%><!DOCTYPE html PUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="/1999/xhtml"><head><title>个人存款计算器</title><link href="../Styles/styles.css;pvf21b76d3545dc298"rel="Stylesheet" type="text/css"/><script language="javascript">function perSaving(){var amount=document.per_form.amountTextBox.valuevar yrate=document.per_form.yRateTextBox.valuevar term=document.per_form.termTextBox.valueif (amount==""){ alert("请输入存款金额!")document.per_form.amountTextBox.focus()window.event.returnValue = false;return}if (yrate==""){alert("请输入年利率或选择期限种类!")document.per_form.yRateTextBox.focus()window.event.returnValue = false;return}if (term==""){alert("请输入存期!")document.per_form.termTextBox.focus()window.event.returnValue = false;return}if(isNaN(amount)){alert("请输入数字!")document.per_form.amountTextBox.focus()window.event.returnValue = false;return}if(isNaN(yrate)){alert("请输入数字!")document.per_form.yRateTextBox.focus()window.event.returnValue = false;return}if(isNaN(term)){alert("请输入数字!")document.per_form.termTextBox.focus()window.event.returnValue = false;return}var taxrate=0.00;var interest=amount*yrate*term*0.01/12var tax=taxrate*amount*yrate*term*0.01/12var result=amount*(1+(1-taxrate)*yrate*term*0.01/12)interest=Math.round(interest*100)interest=interest/100interest=interest+""document.per_form.interestTextBox.value=interesttax=Math.round(tax*100)tax=tax/100tax=tax+""document.per_form.taxTextBox.value=taxresult=Math.round(result*100)result=result/100result=result+""document.per_form.resultTextBox.value=resultwindow.event.returnValue = false;}</script><script language="javascript">function checkTerm(){var during=document.per_form.duringDropDownlist.valuevar currencyDropDownList=document.per_form.currencyDropDownList.valueif(currencyDropDownList=="人民币"){if(during=="活期"){document.per_form.termTextBox.value ="";document.per_form.yRateTextBox.value="0.5000";}if(during=="通知存款一天"){document.per_form.termTextBox.value ="";document.per_form.yRateTextBox.value="0.9500"; }if(during=="通知存款七天"){document.per_form.termTextBox.value ="";document.per_form.yRateTextBox.value="1.4900"; }if(during=="整存整取三个月"){document.per_form.termTextBox.value ="03";document.per_form.yRateTextBox.value="3.1000"; }if(during=="整存整取半年"){document.per_form.termTextBox.value ="06";document.per_form.yRateTextBox.value="3.3000"; }if(during=="整存整取一年"){document.per_form.termTextBox.value ="12";document.per_form.yRateTextBox.value="3.5000"; }if(during=="整存整取二年"){document.per_form.termTextBox.value ="24";document.per_form.yRateTextBox.value="4.4000"; }if(during=="整存整取三年"){document.per_form.termTextBox.value ="36";document.per_form.yRateTextBox.value="5.0000"; }if(during=="整存整取五年"){document.per_form.termTextBox.value ="60";document.per_form.yRateTextBox.value="5.5000"; }if(during=="零存整取一年"){document.per_form.termTextBox.value ="12";document.per_form.yRateTextBox.value="3.1000"; }if(during=="零存整取三年"){document.per_form.termTextBox.value ="36";document.per_form.yRateTextBox.value="3.3000"; }if(during=="零存整取五年"){document.per_form.termTextBox.value ="60";document.per_form.yRateTextBox.value="3.5000"; }if(during=="整存零取一年"){document.per_form.termTextBox.value ="12";document.per_form.yRateTextBox.value="3.1000"; }if(during=="整存零取三年"){document.per_form.termTextBox.value ="36";document.per_form.yRateTextBox.value="3.3000"; }if(during=="整存零取五年"){document.per_form.termTextBox.value ="60";document.per_form.yRateTextBox.value="3.5000"; }if(during=="零存零取一年"){document.per_form.termTextBox.value ="12";document.per_form.yRateTextBox.value="3.1000";}if(during=="零存零取三年"){document.per_form.termTextBox.value ="36";document.per_form.yRateTextBox.value="3.3000";}if(during=="零存零取五年"){document.per_form.termTextBox.value ="60";document.per_form.yRateTextBox.value="3.5000";}if(during=="存本取息一年"){document.per_form.termTextBox.value ="12";document.per_form.yRateTextBox.value="3.1000";}if(during=="存本取息三年"){document.per_form.termTextBox.value ="36";document.per_form.yRateTextBox.value="3.3000";}if(during=="存本取息五年"){document.per_form.termTextBox.value ="60";document.per_form.yRateTextBox.value="3.5000";}}if(currencyDropDownList=="美元"){if(during=="活期"){document.per_form.termTextBox.value ="";document.per_form.yRateTextBox.value="0.1000";}if(during=="整存整取一个月"){document.per_form.termTextBox.value ="01";document.per_form.yRateTextBox.value="0.2500";}if(during=="整存整取三个月"){document.per_form.termTextBox.value ="03";document.per_form.yRateTextBox.value="0.5000";}if(during=="整存整取半年"){document.per_form.termTextBox.value ="06";document.per_form.yRateTextBox.value="0.7500";}if(during=="整存整取一年"){document.per_form.termTextBox.value ="12";document.per_form.yRateTextBox.value="1.2500";}if(during=="整存整取二年"){document.per_form.termTextBox.value ="24";document.per_form.yRateTextBox.value="1.2500";}}if(currencyDropDownList=="英镑"){if(during=="活期"){document.per_form.termTextBox.value ="";document.per_form.yRateTextBox.value="0.1250";}if(during=="整存整取一个月"){document.per_form.termTextBox.value ="01";document.per_form.yRateTextBox.value="0.2180";}if(during=="整存整取三个月"){document.per_form.termTextBox.value ="03";document.per_form.yRateTextBox.value="0.8050";}if(during=="整存整取半年"){document.per_form.termTextBox.value ="06";document.per_form.yRateTextBox.value="0.9760";}if(during=="整存整取一年"){document.per_form.termTextBox.value ="12";document.per_form.yRateTextBox.value="1.0760";}if(during=="整存整取二年"){document.per_form.termTextBox.value ="24";document.per_form.yRateTextBox.value="1.0760";}}if(currencyDropDownList=="欧元"){if(during=="活期"){document.per_form.termTextBox.value ="";document.per_form.yRateTextBox.value="0.1000";}if(during=="整存整取一个月"){document.per_form.termTextBox.value ="01";document.per_form.yRateTextBox.value="0.7500";}if(during=="整存整取三个月"){document.per_form.termTextBox.value ="03";document.per_form.yRateTextBox.value="1.0000";}if(during=="整存整取半年"){document.per_form.termTextBox.value ="06";document.per_form.yRateTextBox.value="1.1250";}if(during=="整存整取一年"){document.per_form.termTextBox.value ="12";document.per_form.yRateTextBox.value="1.2500";}if(during=="整存整取二年"){document.per_form.termTextBox.value ="24";document.per_form.yRateTextBox.value="1.3125";}}if(currencyDropDownList=="日元"){if(during=="活期"){document.per_form.termTextBox.value ="";document.per_form.yRateTextBox.value="0.0001";}if(during=="整存整取一个月"){document.per_form.termTextBox.value ="01";document.per_form.yRateTextBox.value="0.0100";}if(during=="整存整取三个月"){document.per_form.termTextBox.value ="03";document.per_form.yRateTextBox.value="0.0100";}if(during=="整存整取半年"){document.per_form.termTextBox.value ="06";document.per_form.yRateTextBox.value="0.0100";}if(during=="整存整取一年"){document.per_form.termTextBox.value ="12";document.per_form.yRateTextBox.value="0.0100";}if(during=="整存整取二年"){document.per_form.termTextBox.value ="24";document.per_form.yRateTextBox.value="0.0100";}}if(currencyDropDownList=="港币"){if(during=="活期"){document.per_form.termTextBox.value ="";document.per_form.yRateTextBox.value="0.0200";}if(during=="整存整取一个月"){document.per_form.termTextBox.value ="01";document.per_form.yRateTextBox.value="0.1500";}if(during=="整存整取三个月"){document.per_form.termTextBox.value ="03";document.per_form.yRateTextBox.value="0.4000";}if(during=="整存整取半年"){document.per_form.termTextBox.value ="06";document.per_form.yRateTextBox.value="0.5000";}if(during=="整存整取一年"){document.per_form.termTextBox.value ="12";document.per_form.yRateTextBox.value="0.8000";}if(during=="整存整取二年"){document.per_form.termTextBox.value ="24";document.per_form.yRateTextBox.value="1.1000";}}if(currencyDropDownList=="加拿大元"){if(during=="活期"){document.per_form.termTextBox.value ="";document.per_form.yRateTextBox.value="0.0400";}if(during=="整存整取一个月"){document.per_form.termTextBox.value ="01";document.per_form.yRateTextBox.value="0.2165";}if(during=="整存整取三个月"){document.per_form.termTextBox.value ="03";document.per_form.yRateTextBox.value="0.3915";}if(during=="整存整取半年"){document.per_form.termTextBox.value ="06";document.per_form.yRateTextBox.value="0.5100";}if(during=="整存整取一年"){document.per_form.termTextBox.value ="12";document.per_form.yRateTextBox.value="0.7315";}if(during=="整存整取二年"){document.per_form.termTextBox.value ="24";document.per_form.yRateTextBox.value="0.7315";}}if(currencyDropDownList=="瑞士法郎"){if(during=="活期"){document.per_form.termTextBox.value ="";document.per_form.yRateTextBox.value="0.0001";}if(during=="整存整取一个月"){document.per_form.termTextBox.value ="01";document.per_form.yRateTextBox.value="0.0100";}if(during=="整存整取三个月"){document.per_form.termTextBox.value ="03";document.per_form.yRateTextBox.value="0.0100";}if(during=="整存整取半年"){document.per_form.termTextBox.value ="06";document.per_form.yRateTextBox.value="0.0100";}if(during=="整存整取一年"){document.per_form.termTextBox.value ="12";document.per_form.yRateTextBox.value="0.0100";}if(during=="整存整取二年"){document.per_form.termTextBox.value ="24";document.per_form.yRateTextBox.value="0.0100";}}if(currencyDropDownList=="澳大利亚元"){if(during=="活期"){document.per_form.termTextBox.value ="";document.per_form.yRateTextBox.value="0.2375";}if(during=="整存整取一个月"){document.per_form.termTextBox.value ="01";document.per_form.yRateTextBox.value="1.2400";}if(during=="整存整取三个月"){document.per_form.termTextBox.value ="03";document.per_form.yRateTextBox.value="1.3875";}if(during=="整存整取半年"){document.per_form.termTextBox.value ="06";document.per_form.yRateTextBox.value="1.5075";}if(during=="整存整取一年"){document.per_form.termTextBox.value ="12";document.per_form.yRateTextBox.value="1.5750";}if(during=="整存整取二年"){document.per_form.termTextBox.value ="24";document.per_form.yRateTextBox.value="1.5750";}}if(currencyDropDownList=="新加坡元"){if(during=="活期"){document.per_form.termTextBox.value ="";document.per_form.yRateTextBox.value="0.0001";}if(during=="整存整取一个月"){document.per_form.termTextBox.value ="01";document.per_form.yRateTextBox.value="0.0100";}if(during=="整存整取三个月"){document.per_form.termTextBox.value ="03";document.per_form.yRateTextBox.value="0.0100";}if(during=="整存整取半年"){document.per_form.termTextBox.value ="06";document.per_form.yRateTextBox.value="0.7500";}if(during=="整存整取一年"){document.per_form.termTextBox.value ="12";document.per_form.yRateTextBox.value="0.0100";}if(during=="整存整取二年"){document.per_form.termTextBox.value ="24";document.per_form.yRateTextBox.value="0.0100";}}}</script></head><body><form name="per_form"method="post"action="xxx_check.jsp"id="per_form"><div><table class="black"cellSpacing="0"cellPadding="0"width="723" border="0"><tr><td vAlign="top"height="366"><table cellSpacing="0"cellPadding="0"width="100%"align="middle"borderColorDark="#ffffff"borderColorLight="#cccccc"border="1"><tr bgColor="#e0e0e0"><td colSpan="4"height="30"><div class="20"align="center"><font color="#cc0000"><strong>个人存款计算器</strong></font></div></td></tr><tr><td align="center"valign="top"><br><table cellSpacing="0"bgColor="#ffffff"borderColorDark="#ffffff"cellPadding="3"width="80%"borderColorLight="darkgray"border="1"><tr><td align="right"><span class="content">币种</span></td><td align="left"><select name="currencyDropDownList" onchange="on_currencyDropDownList_selected()"id="currencyDropDownList"> <option selected="selected"value="人民币">人民币</option><option value="美元">美元</option><option value="英镑">英镑</option><option value="欧元">欧元</option><option value="日元">日元</option><option value="港币">港币</option><option value="加拿大元">加拿大元</option><option value="瑞士法郎">瑞士法郎</option><option value="澳大利亚元">澳大利亚元</option><option value="新加坡元">新加坡元</option></select></td></tr><tr><td align="right"><span class="content">期限种类</span></td><td align="left"><select name="duringDropDownlist" onchange="javascript:checkTerm();"id="duringDropDownlist"> <option selected="selected"value="请选择期限种类">请选择期限种类</option> <option value="活期">活期</option><option value="通知存款一天">通知存款一天</option><option value="通知存款七天">通知存款七天</option><option value="整存整取三个月">整存整取三个月</option><option value="整存整取半年">整存整取半年</option><option value="整存整取一年">整存整取一年</option><option value="整存整取二年">整存整取二年</option><option value="整存整取三年">整存整取三年</option><option value="整存整取五年">整存整取五年</option><option value="零存整取一年">零存整取一年</option><option value="零存整取三年">零存整取三年</option><option value="零存整取五年">零存整取五年</option><option value="整存零取一年">整存零取一年</option><option value="整存零取三年">整存零取三年</option><option value="整存零取五年">整存零取五年</option><option value="存本取息一年">存本取息一年</option><option value="存本取息三年">存本取息三年</option><option value="存本取息五年">存本取息五年</option></select></td></tr><tr><td align="right"><span class="content">存款金额</span></td><td align="left"><input name="amountTextBox"type="text"id="amountTextBox"style="width:130px;"/><spanclass="content">元</span></td></tr><tr><td align="right"><span class="content">年利率</span></td><td align="left"><input name="yRateTextBox"type="text"id="yRateTextBox"style="color:#404040;width:130px;"/><span class="content">(%)</span></td></tr><tr><td align="right"><span class="content">存期</span></td><td align="left"><input name="termTextBox"type="text"id="termTextBox"style="width:130px;"/><span class="content">月</span></td></tr><tr bgColor="#e0e0e0"><td align="right"><span class="content">利息</span></td><td align="left"><input name="interestTextBox"type="text"readonly="readonly"id="interestTextBox"style="width:130px;" /><span class="content">元</span></td></tr><tr bgColor="#e0e0e0"><td align="right"><span class="content">扣除利息税</span></td><td align="left"><input name="taxTextBox"type="text"readonly="readonly"id="taxTextBox"style="width:130px;"/><span class="content">元</span></td></tr><tr bgColor="#e0e0e0"><td align="right"><span class="content">本息合计(税后)</span></td><td align="left"><input name="resultTextBox"type="text"readonly="readonly"id="resultTextBox"style="width:130px;" /><span class="content">元</span><input type="image"name="calculateImageButton" id="calculateImageButton"src="../images/calculator_button.gif"alt="计算"align="bottom"onclick="javascript:perSaving();"style="height:21px;border-width:0px;"/></td></tr></table><br></td></tr></table></td></tr></table><P></P></div></form><script type="text/javascript"><!--var data = {};data['人民币'] = ['活期','通知存款一天','通知存款七天', '整存整取三个月','整存整取半年','整存整取一年','整存整取二年', '整存整取三年', '整存整取五年', '零存整取一年', '零存整取三年', '零存整取五年','整存零取一年', '整存零取三年', '整存零取五年', '存本取息一年', '存本取息三年', '存本取息五年' ];data['美元'] = ['活期', '整存整取一个月', '整存整取三个月','整存整取半年','整存整取一年','整存整取二年'];data['英镑'] = ['活期', '整存整取一个月', '整存整取三个月','整存整取半年','整存整取一年','整存整取二年'];data['欧元'] = ['活期', '整存整取一个月', '整存整取三个月','整存整取半年','整存整取一年','整存整取二年'];data['日元'] = ['活期', '整存整取一个月', '整存整取三个月','整存整取半年','整存整取一年','整存整取二年'];data['港币'] = ['活期', '整存整取一个月', '整存整取三个月','整存整取半年','整存整取一年','整存整取二年'];data['加拿大元'] = ['活期', '整存整取一个月', '整存整取三个月','整存整取半年','整存整取一年','整存整取二年'];data['瑞士法郎'] = ['活期', '整存整取一个月', '整存整取三个月','整存整取半年','整存整取一年','整存整取二年'];data['澳大利亚元'] = ['活期', '整存整取一个月', '整存整取三个月','整存整取半年','整存整取一年','整存整取二年'];data['新加坡元'] = ['活期', '整存整取一个月', '整存整取三个月','整存整取半年','整存整取一年','整存整取二年'];var currencyDropDownList=document.getElementById('currencyDropDownList');var duringDropDownlist = document.getElementById('duringDropDownlist'); function on_currencyDropDownList_selected(){var children = data[currencyDropDownList.value];duringDropDownlist.innerHTML = '';var str = '';for(var i in children){var c = children[i];var opt = document.createElement("option");opt.value = c;opt.innerHTML = c;duringDropDownlist.appendChild(opt);}}//--></script></body></html>。

java项目ATM银行系统源代码

java项目ATM银行系统源代码

//初始密码为123456import java.awt.*;import java.awt.event.*;import javax.swing.*;public class MyATM extends JFrame implements ActionListener{JPanelpanelfirst,panelmain,panel3,panel4,panel5,panel6,panel7,panelchangepwd,panelchangep wded,panelsave,panelsaved,panelremain,paneltrans,paneltransed,panelmobile,panelmobi led,panelconsult;JButtonbtn0,btn1,btn2,btn3,btn4,btn5,btn6,btn7,btn8,btn9,btn10,btnsure,btnback,btnok,btnca rd,btngetcard,btnincard;JButtonbtn00,btn01,btn02,btn03,btn04,btn05,btn06,btn07,btn08,btn09,btn010,btnback1,btnrema in,btnremain1,btnremain2;JButtonbtn000,btn001,btn002,btn003,btn004,btn005,btn006,btn007,btn008,btn009,btn100,btn200 ,btn300,btn1000,btn500,btnsure1,btnback2,btn0010,btnquok1,btnquok2,btnquok3,btnquok 4;JButtonbtnpwd,btnpwd1,btnpwd2,btnpwd3,btnpwd4,btn11,btn12,btn13,btn14,btn15,btn16,btn17,bt n18,btn19,btn20,btnsave,btnsave1,btnsave2,btnsaved,btnsaved1,btnsaved2,btnsaved3;JButtonbtntra,btntra1,btntra2,btntraed,btntraed1,btn21,btn22,btn23,btn24,btn25,btn26,btn27 ,btn28,btn29,btn30,btncon,btncon1;JButtonbtnmo,btnmo1,btnmo2,btnmo30,btnmo50,btnmo100,btnmo200,btnmo500,btnmo10,btnmo11,btnm o12,btnmo13,btnmo14,btnmo15,btnmo16,btnmo17,btnmo18,btnmo19,btnmoed,btnmoed1;JTextField txt2,txttrans,txttrans1,txttrans2,txtmo,txtmo1;JLabellbljixu,lblpwd,lblwrong,lblqukuan,lblquok1,lblquok2,lblpwd1,lblpwd2,lblpwd3,lblpwd4 ,lblsave,lblsave1,lblsaved,lblremain,lblremain1,lbltra,lbltra1,lbltra2,lbltraed,lbl traed1;JLabellblwel,lblwel1,lblmo,lblmo1,lblmo2,lblmo3,lblmoed,lblmoed1,lblcon,lblcon1;JPasswordField txt1,txtpwd,txtpwd1;Container container;CardLayout Layout;int money,savemoney,mobilemoney=0;double lastmoney,trainsmoney;String userpwd,cardnum,trains,username;boolean flag=true,flag1=false,flag2=false,flag3=true,flag4=false,flag5=false;//构造方法public MyATM(){super("罗灿银行");this.setSize(435,350);this.setLocation(500, 250);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE );//设置不可改变窗口大小this.setResizable(false);//设置程序小图标this.setIconImage(this.getToolkit().getImage("images\\haizei.jpg"));}//布局public void setLayout(){//用卡片布局Layout=new CardLayout();container=getContentPane();container.setLayout(Layout);//添加第一张卡片panelfirst=new JPanel(null);//设置卡片的背景颜色panelfirst.setBackground(new Color(119,119,253));lbljixu=new JLabel("请放入磁卡,然后继续操作");//设置卡片在Panel中的位置lbljixu.setBounds(140,90,350,30);//为第一张卡片添加一个Labelpanelfirst.add(lbljixu);//为第一张卡片添加一个按钮btncard=new JButton("继续");btncard.setBounds(310,180,80,30);//为按钮注册事件监听器btncard.addActionListener(this);//开始时设置按钮不可按btncard.setEnabled(false);panelfirst.add(btncard);//为第一张卡片添加一个按钮btngetcard=new JButton("取卡");btngetcard.setEnabled(false);btngetcard.setBounds(310,220,80,30); btngetcard.addActionListener(this);panelfirst.add(btngetcard);//为第一张卡片添加一个按钮btnincard=new JButton("插卡");btnincard.setBounds(40,220,80,30);btnincard.addActionListener(this);panelfirst.add(btnincard);container.add(panelfirst,"first");//添加登录输入密码卡片panelmain=new JPanel(null);panelmain.setBackground(new Color(119,119,253)); lblpwd=new JLabel("请输入您的银行卡密码:"); panelmain.add(lblpwd);lblpwd.setBounds(150, 20, 150, 30);//设置文本框为密码型txt1=new JPasswordField(12);//文本框不可选中txt1.enable(false);panelmain.add(txt1);//文本框的输入内容用*显示txt1.setEchoChar('*');txt1.setBounds(115,50,200,30);//添加选择按钮btnsure=new JButton("确定");btnsure.addActionListener(this);panelmain.add(btnsure);btnsure.setBounds(70,160,80,30);//添加重输按钮btn010=new JButton("重输");btn010.addActionListener(this);panelmain.add(btn010);btn010.setBounds(175,160,80,30);btnback=new JButton("退出");btnback.addActionListener(this);panelmain.add(btnback);btnback.setBounds(280,160,80,30);lblwrong=new JLabel("请注意保护好您的密码!"); panelmain.add(lblwrong);lblwrong.setBounds(150,90,200,30);//添加输入按钮btn01=new JButton("1");btn01.addActionListener(this);panelmain.add(btn01);btn01.setBounds(45,210,60,30);btn02=new JButton("2");btn02.addActionListener(this);panelmain.add(btn02);btn02.setBounds(115,210,60,30);btn03=new JButton("3");btn03.addActionListener(this);panelmain.add(btn03);btn03.setBounds(185,210,60,30);btn04=new JButton("4");btn04.addActionListener(this);panelmain.add(btn04);btn04.setBounds(255,210,60,30);btn05=new JButton("5");btn05.addActionListener(this);panelmain.add(btn05);btn05.setBounds(325,210,60,30);btn06=new JButton("6");btn06.addActionListener(this);panelmain.add(btn06);btn06.setBounds(45,260,60,30);btn07=new JButton("7");btn07.addActionListener(this);panelmain.add(btn07);btn07.setBounds(115,260,60,30);container.add(panelmain,"main");btn08=new JButton("8");btn08.addActionListener(this);panelmain.add(btn08);btn08.setBounds(185,260,60,30);btn09=new JButton("9");btn09.addActionListener(this);panelmain.add(btn09);btn09.setBounds(255,260,60,30);btn00=new JButton("0");btn00.addActionListener(this);panelmain.add(btn00);btn00.setBounds(325,260,60,30);//添加主界面卡片panel3=new JPanel(null);panel3.setBackground(new Color(119,119,253));lblwel=new JLabel(username+",欢迎使用罗灿银行ATM系统"); lblwel.setBounds(20,15,350,30);panel3.add(lblwel);lblwel1=new JLabel("请选择您需要的交易类型");lblwel1.setBounds(220,55,350,30);panel3.add(lblwel1);btn3=new JButton("取款服务");btn3.addActionListener(this);btn3.setBounds(20,90,100,30);panel3.add(btn3);btn4=new JButton("修改密码");btn4.addActionListener(this);btn4.setBounds(20,150,100,30);panel3.add(btn4);btn5=new JButton("存款服务");btn5.addActionListener(this);btn5.setBounds(20,210,100,30);panel3.add(btn5);btn6=new JButton("查询余额");btn6.addActionListener(this);btn6.setBounds(20,270,100,30);panel3.add(btn6);btn7=new JButton("转账服务");btn7.addActionListener(this);btn7.setBounds(300,90,100,30);panel3.add(btn7);btn8=new JButton("通信交费");btn8.addActionListener(this);btn8.setBounds(300,150,100,30);panel3.add(btn8);btn9=new JButton("咨询服务");btn9.addActionListener(this);btn9.setBounds(300,210,100,30);panel3.add(btn9);btn10=new JButton("退出操作");btn10.addActionListener(this);btn10.setBounds(300,270,100,30);panel3.add(btn10);container.add(panel3,"three");//添加取款页面卡片panel4=new JPanel(null);panel4.setBackground(new Color(119,119,253));lblqukuan=new JLabel("请输入您的取款数:");panel4.add(lblqukuan);lblqukuan.setBounds(115, 20, 150, 30);lblqukuan=new JLabel("提示:只能是100元或100元的整数倍。

Java-银行管理系统源代码

Java-银行管理系统源代码

Java小型银行管理系统源代码(图形界面)accounts.javapackage Account;public class accounts {p rotected int id;//银行账号p rotected String password;//用户密码p rotected String name;//用户型号p rotected String personId;//身份账号p rotected int accountType;//账号类型,0代表储蓄卡,1代表信用卡p rotected double balance;//账户余额。

之所以定义为protected是让他的子类可以直接用,不需要通过方法来赋值。

p rotected double ceiling;p ublic String getPassword(){return password;}p ublic void setPassword(String password){this.password=password;}p ublic String getName(){return name;}p ublic void setName(String name){=name;}p ublic String getPersonId(){return personId;}p ublic void setPersonId(String personId){this.personId=personId;}p ublic int getAccountType(){return accountType;}p ublic void setAccountType(int accountType){this.accountType=accountType;}public double getBalance(){return balance;}p ublic void setBalance(double balance){this.balance=balance;}p ublic int getId(){return id;}p ublic void setId(int id){this.id=id;}public double getCeiling(){return ceiling;}p ublic void setCeiling(double ceiling){this.ceiling=ceiling;}//无参数构造方法p ublic accounts(){}//构造方法p ublic accounts(String password,String name,String personId,int accountType, double balance,double ceiling){super();this.password=password;=name;this.personId=personId;this.accountType=accountType;this.balance=balance;this.ceiling=ceiling;}//存款p ublic void deposit(double money){balance+=money;}//取款p ublic void withdraw(double money){if(accountType==1){if((balance+ceiling)<money){System.out.println("对不起,已超出您的信用额度!");}else{balance-=money;}}else{if(balance<money){System.out.println("对不起,账户余额不足!");}else{balance-=money;}}}}DBoper.javapackage DB;import java.sql.*;import java.util.ArrayList;import Account.accounts;public class DBoper {p rivate Connection conn = null;p rivate Statement st = null;p rivate PreparedStatement pstmt = null;p rivate ResultSet rs = null;p rivate ArrayList<accounts> result;//连接数据库p ublic Connection getConnection(){try{Class.forName("com.mysql.jdbc.Driver");conn=DriverManager.getConnection("jdbc:mysql://localhost:3306/bankmanager?useUnicod e=true&characterEncoding=utf8","root","xuewei");}catch(Exception e){System.out.println("数据库连接失败");}return conn;}//修改删除用户数据p ublic boolean accountDataUpdate(String sql){conn=getConnection();try{pstmt=conn.prepareStatement(sql);pstmt.executeUpdate();//System.out.println("数据更新成功");conn.close();return true;}catch(SQLException e){e.printStackTrace();//System.out.println("更新失败");return false;}}//依据id来修改记录p ublic boolean dataupdateid(accounts user, int id) {conn = getConnection();try {String sql = "update account set username=?,userpwd=?,personId=?,accountType=?,balance=?,ceiling=? where id="+ id;pstmt = conn.prepareStatement(sql);pstmt.setString(1, user.getName());pstmt.setString(2, user.getPassword());pstmt.setString(3, user.getPersonId());pstmt.setInt(4, user.getAccountType());pstmt.setDouble(5, user.getBalance());pstmt.setDouble(6, user.getCeiling());pstmt.executeUpdate();System.out.println("操作成功");return true;}catch (SQLException e) {e.printStackTrace();System.out.println("操作失败");return false;}}//插入用户数据p ublic boolean accountDataInsert(accounts account){conn=getConnection();try{pstmt=conn.prepareStatement("insert into account (username,userpwd,personId,accountType,balance,ceiling) values (?,?,?,?,?,?)");pstmt.setString(1, account.getName());pstmt.setString(2, account.getPassword());pstmt.setString(3, account.getPersonId());pstmt.setInt(4, account.getAccountType());pstmt.setDouble(5, account.getBalance());pstmt.setDouble(6, account.getCeiling());pstmt.executeUpdate();System.out.println("新用户数据插入成功");conn.close();return true;}catch(SQLException e){e.printStackTrace();System.out.println("插入失败");return false;}}//查询数据p ublic ResultSet dataquery(String sql) {conn = getConnection();try {pstmt = conn.prepareStatement(sql);rs = pstmt.executeQuery();}catch (SQLException e) {e.printStackTrace();System.out.println("检索失败");}return rs;}p ublic ResultSet testlist() {try {String sql = "select * from account where id =1001";pstmt = conn.prepareStatement(sql);System.out.println(sql);rs = pstmt.executeQuery();} catch (SQLException e) {e.printStackTrace();System.out.println("检索失败");}return rs;}p ublic ArrayList<accounts> testt(int id) {ArrayList<accounts> list = new ArrayList<accounts>();conn = getConnection();try {String sql = "select * from account where id=" + id;pstmt = conn.prepareStatement(sql);rs = pstmt.executeQuery();while (rs.next()) {accounts user = new accounts();user.setName(rs.getString("username"));user.setPassword(rs.getString("userpwd"));user.setPersonId(rs.getString("personId"));user.setAccountType(rs.getInt("accountType"));user.setBalance(rs.getDouble("balance"));user.setCeiling(rs.getDouble("ceiling"));list.add(user);}}catch (SQLException e) {e.printStackTrace();System.out.println("检索失败");}return list;}//根据卡号和密码验证用户是否存在p ublic boolean verify(int id,String password){conn=getConnection();try{pstmt=conn.prepareStatement("select * from account where id=? and userpwd=?");pstmt.setInt(1, id);pstmt.setString(2, password);rs=pstmt.executeQuery();if(rs.next()){return true;}else{return false;}}catch(SQLException e){e.printStackTrace();return false;}}/*** 登录验证*/p ublic accounts verifyAccount(int id, String password) {boolean flag = verify(id, password);if(flag){accounts account=queryByIDandPassword(id, password);return account;}else{System.out.println("用户不存在!");return null;}}//根据卡号和密码查询信息p ublic accounts queryByIDandPassword(int id,String password){conn=getConnection();try{pstmt=conn.prepareStatement("select * from account where id=? and userpwd=?");pstmt.setInt(1, id);pstmt.setString(2, password);rs=pstmt.executeQuery();accounts account=new accounts();while(rs.next()){account.setId(rs.getInt("id"));account.setName(rs.getString("username"));account.setPassword(rs.getString("userpwd"));account.setPersonId(rs.getString("personId"));account.setAccountType(rs.getInt("accountType"));account.setBalance(rs.getDouble("balance"));account.setCeiling(rs.getDouble("ceiling"));}return account;}catch(SQLException e){e.printStackTrace();return null;}}//根据卡号查询信息p ublic accounts queryByID(int id){conn=getConnection();try{pstmt=conn.prepareStatement("select * from account where id=?");pstmt.setInt(1, id);rs=pstmt.executeQuery();accounts account=new accounts();while(rs.next()){account.setId(rs.getInt("id"));account.setName(rs.getString("username"));account.setPassword(rs.getString("userpwd"));account.setPersonId(rs.getString("personId"));account.setAccountType(rs.getInt("accountType"));account.setBalance(rs.getDouble("balance"));account.setCeiling(rs.getDouble("ceiling"));}return account;}catch(SQLException e){e.printStackTrace();return null;}}p ublic static void main(String[] args) {// TODO Auto-generated method stubDBoper op=new DBoper();ArrayList<accounts> list=op.testt(1001);for(int i=0;i<list.size();i++){accounts user=new accounts();user=list.get(i);System.out.println(user.getName());System.out.println(user.getPassword());System.out.println(user.getPersonId());System.out.println(user.getAccountType());System.out.println(user.getBalance());System.out.println(user.getCeiling());}}}//图像界面文件夹DN_SYSTEMDefault.java //主界面package DN_SYSTEM;import java.awt.Color;import java.awt.Container;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.WindowConstants;import Account.accounts;import DB.DBoper;public class Default extends JFrame implements ActionListener{a ccounts account=DN_ATM.client;D Boper db=new DBoper();p rivate JFrame jf;p rivate JButton btn0,btn1,btn2,btn3,btn4,btn5;p rivate Container c;p ublic void defaltDemo() {//添加主界面卡片//DN_ATM.id;int id=DN_ATM.id;//account=db.queryByID(id);jf=new JFrame("DEFAULT");c=jf.getContentPane();c.setLayout(null);c.setBackground(new Color(119,119,253));JLabel lblwel = new JLabel("欢迎"+account.getName()+"用达能银行ATM系统");lblwel.setBounds(20, 15, 350, 30);c.add(lblwel);JLabel lblwel1 = new JLabel("请选择您需要的交易类型");lblwel1.setBounds(120, 45, 350, 30);c.add(lblwel1);btn1 = new JButton("取款服务");btn1.addActionListener(this);btn1.setBounds(70, 90, 100, 30);c.add(btn1);btn2=new JButton("存款服务");btn2.addActionListener(this);btn2.setBounds(210, 90, 100, 30);c.add(btn2);btn3 = new JButton("查询余额");btn3.addActionListener(this);btn3.setBounds(70, 150, 100, 30);c.add(btn3);btn4 = new JButton("转账服务");btn4.addActionListener(this);btn4.setBounds(210, 150, 100, 30);c.add(btn4);btn5 = new JButton("注销账户");btn5.addActionListener(this);btn5.setBounds(70, 210, 100, 30);c.add(btn5);btn0 = new JButton("退出操作");btn0.addActionListener(this);btn0.setBounds(210, 210, 100, 30);c.add(btn0);jf.setVisible(true);jf.setResizable(false);jf.setSize(400,300);jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); }//事件处理@Overridep ublic void actionPerformed(ActionEvent e){//取款服务if(e.getSource().equals(btn1)){OutMoney outmoney=new OutMoney();outmoney.outMoney();jf.dispose();}//存款服务if(e.getSource().equals(btn2)){InMoney inmoney=new InMoney();inmoney.InMoney();jf.dispose();}//查询余额if(e.getSource().equals(btn3)){GetBalance getbalance=new GetBalance();getbalance.getBalance();jf.dispose();}//转账服务if(e.getSource().equals(btn4)){TransferAccounts tranfer=new TransferAccounts();tranfer.transferAccounts();jf.dispose();}//注销账户if(e.getSource().equals(btn5)){String sql="delete from account where id="+account.getId();boolean flag=db.accountDataUpdate(sql);if(flag){JOptionPane.showMessageDialog(this,"注销成功!");}else{JOptionPane.showMessageDialog(this, "注销失败!");}}if(e.getSource().equals(btn0)){System.exit(0);}}p ublic static void main(String[] args) {// TODO Auto-generated method stubDefault defaults=new Default();defaults.defaltDemo();}}DN_ATM.java //功能界面package DN_SYSTEM;import java.awt.CardLayout;import java.awt.Color;import java.awt.Container;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.AbstractButton;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JPasswordField;import javax.swing.JTextField;import DB.DBoper;import Account.accounts;public class DN_ATM extends JFrame implements ActionListener{ p rivate JLabel lbljixu;private JButton btngetcard;p rivate JButton btncard,btn010,btn_addAccount,btnsure,btnback;p rivate JTextField txt1;p rivate JPasswordField txt2;p rivate Container container;p rivate CardLayout Layout;p rivate JLabel lblwrong;p rivate JPanel panelfirst,panelmain;p ublic static int id;s tatic accounts client = null;p ublic DN_ATM(){super("达能银行");this.setSize(435, 350);this.setLocation(500,250);this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);//设置不可改变窗口大小this.setResizable(false);}//布局public void setLayout(){//用卡片布局Layout = new CardLayout();container = getContentPane();container.setLayout(Layout);//添加第一张卡片panelfirst = new JPanel(null);//设置卡片的背景颜色panelfirst.setBackground(new Color(119,119,253));lbljixu = new JLabel("请放入磁卡,然后继续操作");//设置卡片在Panel中的位置lbljixu.setBounds(140, 90, 350, 30);//为第一张卡片添加一个Labelpanelfirst.add(lbljixu);//为第一张卡片添加一个按钮btncard = new JButton("继续");btncard.setBounds(310, 180, 80, 30);//为按钮注册事件监听器btncard.addActionListener(this);//开始时设置按钮不可按btncard.setEnabled(false);panelfirst.add(btncard);//为第一张卡片添加一个按钮btngetcard = new JButton("取卡");btngetcard.setEnabled(false);btngetcard.setBounds(310, 220, 80, 30);btngetcard.addActionListener(this);panelfirst.add(btngetcard);//添加登录输入卡片panelmain = new JPanel(null);panelmain.setBackground(new Color(119,119,253));//添加登录输入卡号JLabel lblnumber = new JLabel("请输入您的银行卡卡号:"); panelmain.add(lblnumber);lblnumber.setBounds(30, 30, 150, 30);//设置文本框为密码型txt1 = new JTextField(12);//文本框不可选中//txt1.enable(false);panelmain.add(txt1);txt1.setBounds(170, 30, 200, 30);JLabel lblpwd = new JLabel("请输入您的银行卡密码:"); panelmain.add(lblpwd);lblpwd.setBounds(30, 80, 150, 30);//设置文本框为密码型txt2 = new JPasswordField(12);//文本框不可选中//txt2.enable(false);panelmain.add(txt2);//文本框的输入内容用*显示txt2.setEchoChar('*');txt2.setBounds(170, 80, 200, 30);//添加选择按钮btnsure = new JButton("确定");btnsure.addActionListener(this);panelmain.add(btnsure);btnsure.setBounds(70, 160, 80, 30);//添加重输按钮btn010 = new JButton("重输");btn010.addActionListener(this);panelmain.add(btn010);btn010.setBounds(175,160,80,30);btnback = new JButton("退出");btnback.addActionListener(this);panelmain.add(btnback);btnback.setBounds(280, 160, 80, 30);//开户btn_addAccount = new JButton("开户");btn_addAccount.setBounds(70, 220, 80, 30);btn_addAccount.addActionListener(this);panelmain.add(btn_addAccount);lblwrong = new JLabel("请注意保护好您的密码!");panelmain.add(lblwrong);lblwrong.setBounds(180, 110, 200, 30);container.add(panelmain, "main");}//事件处理@SuppressWarnings("deprecation")@Overridep ublic void actionPerformed(ActionEvent e){DBoper db=new DBoper();if(e.getSource().equals(btn_addAccount)){OpenAccount open=new OpenAccount();open.adduser();}//磁卡插入后,验证银行登录卡号与密码if(e.getSource().equals(btnsure)){client = db.verifyAccount(Integer.parseInt(txt1.getText()), txt2.getText());if(client!=null){Default defa=new Default();defa.defaltDemo();this.dispose();id=Integer.parseInt(txt1.getText());txt1.setText("");txt2.setText("");}else{lblwrong.setText("卡号或密码不正确,请重新输入!");txt1.setText("");txt2.setText("");}}//重置输入卡号和密码if(e.getSource()==btn010){txt1.setText("");txt2.setText("");lblwrong.setText("请注意保护好您的密码!");}//退出if(e.getSource().equals(btnback)){System.exit(0);}}p ublic static void main(String[] args) {// TODO Auto-generated method stubDN_ATM ATM=new DN_ATM();ATM.setLayout();ATM.setVisible(true);}}GetBalance.java //查询余额package DN_SYSTEM;import java.awt.CardLayout;import java.awt.Color;import java.awt.Container;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JPanel;import javax.swing.WindowConstants;import Account.accounts;import DB.DBoper;public class GetBalance extends JFrame implements ActionListener{ p rivate JFrame jf;p rivate Container c;p rivate JLabel lblremain1,lblremain;p rivate JButton btnremain,btnremain1;a ccounts account=new accounts();D Boper db=new DBoper();p rivate int id=DN_ATM.id;//添加查询余额界面卡片p ublic void getBalance(){account=db.queryByID(id);jf=new JFrame("FIND DALANCE");c=jf.getContentPane();c.setLayout(null);jf.setResizable(false);c.setBackground(new Color(119,119,253));lblremain1 = new JLabel("尊敬的达能用户您好!");lblremain1.setBounds(90,70,350,30);c.add(lblremain1);lblremain = new JLabel("请点击继续操作查询余额:");lblremain.setBounds(90,110,350,30);c.add(lblremain);btnremain = new JButton("继续操作");btnremain.setBounds(95,150,90,30);btnremain.addActionListener(this);c.add(btnremain);btnremain1 = new JButton("退出操作");btnremain1.setBounds(200,150,90,30);btnremain1.addActionListener(this);c.add(btnremain1);jf.setVisible(true);jf.setSize(400,300);jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);}@Overridep ublic void actionPerformed(ActionEvent e){//查询余额if(e.getSource()==btnremain){lblremain1.setText("卡号:"+account.getId()+" 用户名:"+account.getName());lblremain.setText("您的余额为"+account.getBalance()+"元,是否继续操作?");}if(e.getSource()==btnremain1){Default defa=new Default();defa.defaltDemo();jf.dispose();}}p ublic static void main(String[] args) {// TODO Auto-generated method stubGetBalance balance=new GetBalance();balance.getBalance();}}InMoney.java //存款package DN_SYSTEM;import java.awt.CardLayout;import java.awt.Color;import java.awt.Container;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JTextField;import javax.swing.WindowConstants;import Account.accounts;import DB.DBoper;public class InMoney extends JFrame implements ActionListener{p rivate JLabel lblsave,lblsave1;p rivate JButton btnsave,btnsave2;p rivate JTextField txt2;p rivate double savemoney ;p rivate double lastmoney;p rivate boolean flag;p rivate JFrame jf;p rivate Container c;a ccounts account=new accounts();D Boper db=new DBoper();p rivate int id=DN_ATM.id;p ublic void InMoney(){account=db.queryByID(id);jf=new JFrame("IN MONEY");c=jf.getContentPane();c.setLayout(null);jf.setResizable(false);//添加存款显示界面卡片c.setBackground(new Color(119,119,253));lblsave = new JLabel("请在存款口处放入存款");lblsave.setBounds(60,30,350,30);c.add(lblsave);lblsave1 = new JLabel("请注意:只接收100元或100元的整数倍存款");lblsave1.setBounds(90,110,350,30);c.add(lblsave1);txt2 = new JTextField(12);c.add(txt2);txt2.setBounds(95, 80, 200, 30);btnsave = new JButton("放入存款完毕");btnsave.setBounds(90,160,120,30);btnsave.addActionListener(this);c.add(btnsave);btnsave2 = new JButton("返回");btnsave2.setBounds(240,160,60,30);btnsave2.addActionListener(this);c.add(btnsave2);jf.setVisible(true);jf.setSize(400,300);jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE);}@Overridep ublic void actionPerformed(ActionEvent e){if(e.getSource()==btnsave){savemoney=Double.parseDouble(txt2.getText());lastmoney=account.getBalance();lastmoney+=savemoney;String sql = "update account set balance="+lastmoney+"where id="+ id;flag=db.accountDataUpdate(sql);if(flag){JOptionPane.showMessageDialog(this, "存款成功!");txt2.setText("");Default defa=new Default();defa.defaltDemo();jf.dispose();}else{JOptionPane.showMessageDialog(this, "存款失败!");}}if(e.getSource()==btnsave2){Default defa=new Default();defa.defaltDemo();jf.dispose();}}p ublic static void main(String[] args) {// TODO Auto-generated method stubInMoney inmoney=new InMoney();inmoney.InMoney();}}OpenAccount.java //开户package DN_SYSTEM;import ponent;import java.awt.Container;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;import javax.swing.ButtonGroup;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPasswordField;import javax.swing.JRadioButton;import javax.swing.JTextField;import javax.swing.WindowConstants;import DB.DBoper;import Account.accounts;public class OpenAccount extends JFrame implements ActionListener{p rivate JFrame jf;p rivate Container c;p rivate JTextField txtname,txt_personId;p rivate JPasswordField txtpwd,txtpwd1;p rivate JRadioButton rbt1;p rivate JRadioButton rbt2;S tring accountType;//开户,增加新用户p ublic void adduser(){jf=new JFrame("Open Account");c=jf.getContentPane();c.setLayout(null);jf.setResizable(false);JLabel lbname=new JLabel("用户名:");lbname.setBounds(100, 40, 80, 20);txtname=new JTextField();txtname.setBounds(160, 40, 130, 20);c.add(lbname);c.add(txtname);JLabel lbpwd=new JLabel("密码:");lbpwd.setBounds(110, 65, 80, 20);txtpwd=new JPasswordField();txtpwd.setBounds(160, 65, 130, 20);txtpwd.setEchoChar('*');c.add(lbpwd);c.add(txtpwd);JLabel lbpwd1=new JLabel("确认密码:");lbpwd1.setBounds(86, 90, 80, 20);txtpwd1 = new JPasswordField();txtpwd1.setBounds(160, 90, 130, 20);txtpwd1.setEchoChar('*');c.add(lbpwd1);c.add(txtpwd1);JLabel lbpersonId=new JLabel("身份证号:");lbpersonId.setBounds(86, 115, 80, 20);txt_personId = new JTextField();txt_personId.setBounds(160, 115, 130, 20);c.add(lbpersonId);c.add(txt_personId);JLabel lbtype=new JLabel("账户类型:");lbtype.setBounds(86, 120, 80, 60);rbt1=new JRadioButton("信用卡");rbt1.setBounds(160, 135, 70, 30);rbt2=new JRadioButton("储蓄卡");rbt2.setBounds(225, 135, 70, 30);ButtonGroup group=new ButtonGroup();group.add(rbt2);group.add(rbt1);c.add(lbtype);c.add(rbt2);c.add(rbt1);JButton btnsubmit=new JButton("提交");btnsubmit.setBounds(100, 190, 80, 20);JButton btnreset=new JButton("重置");btnreset.setBounds(205, 190, 80, 20);c.add(btnsubmit);c.add(btnreset);btnsubmit.addActionListener(this);btnreset.addActionListener(this);jf.setVisible(true);jf.setSize(400,300);jf.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); }p ublic static void main(String[] args) {// TODO Auto-generated method stubOpenAccount openA=new OpenAccount();openA.adduser();}@Overridep ublic void actionPerformed(ActionEvent e){accounts account=new accounts();account.setName(txtname.getText());if(txtpwd.getText().equals(txtpwd1.getText())){account.setPassword(txtpwd.getText());}else{JOptionPane.showMessageDialog(this,"两次输入的密码不一致,请重新输入!");}account.setPersonId(txt_personId.getText());if(rbt1.isSelected())accountType="1";if(rbt2.isSelected())accountType="0";account.setAccountType(Integer.parseInt(accountType));account.setBalance(0);if(accountType.equals("1")){account.setCeiling(5000.0);}else{account.setCeiling(0);}DBoper db=new DBoper();if(db.accountDataInsert(account)){JOptionPane.showMessageDialog(this,"开户成功!");jf.dispose();//关闭当前登录窗体return;}else{JOptionPane.showMessageDialog(this,"开户失败!");return;}}}OutMoney.java //取款package DN_SYSTEM;import java.awt.CardLayout;import java.awt.Color;import java.awt.Container;import javax.swing.JButton;import javax.swing.JFrame;import javax.swing.JLabel;import javax.swing.JOptionPane;import javax.swing.JPanel;import javax.swing.JTextField;import javax.swing.WindowConstants;import Account.accounts;import DB.DBoper;import java.awt.event.ActionEvent;import java.awt.event.ActionListener;public class OutMoney extends JFrame implements ActionListener{p rivate JFrame jf;p rivate JButton btn100,btn200,btn300,btn500,btn1000;p rivate JButton btn001,btn002,btn003,btn004,btn005,btn006,btn007,btn008,btn009,btn000;p rivate JButton btnsure1,btn0010,btnback2;p rivate JTextField txt2;p rivate Container c;p rivate JLabel lblqukuan;p rivate int money;p rivate double lastmoney;a ccounts account=new accounts();D Boper db=new DBoper();p rivate int id=DN_ATM.id;p ublic void outMoney(){account=db.queryByID(id);jf=new JFrame("OUT MONEY");c=jf.getContentPane();c.setLayout(null);jf.setResizable(false);//添加取款页面卡片//panel4=new JPanel(null);c.setBackground(new Color(119,119,253));lblqukuan = new JLabel("请输入您的取款金额:");c.add(lblqukuan);lblqukuan.setBounds(115, 20, 150, 30);lblqukuan=new JLabel("提示:只能是100元或100元的整数倍");c.add(lblqukuan);lblqukuan.setBounds(115, 50, 300, 30);txt2 = new JTextField(12);txt2.enable(false);c.add(txt2);txt2.setBounds(115, 90, 200, 30);btn100 = new JButton("100");c.add(btn100);btn100.addActionListener(this);btn100.setBounds(45, 190, 60, 30);btn200 = new JButton("200");c.add(btn200);btn200.addActionListener(this);btn200.setBounds(115, 190, 60, 30);btn300 = new JButton("300");c.add(btn300);btn300.addActionListener(this);btn300.setBounds(185, 190, 60, 30);btn500 = new JButton("500");btn500=new JButton("500");c.add(btn500);btn500.addActionListener(this);btn500.setBounds(255, 190, 60, 30);btn1000 = new JButton("1000");c.add(btn1000);btn1000.addActionListener(this);btn1000.setBounds(325, 190, 65, 30);btn001 = new JButton("1");c.add(btn001);btn001.addActionListener(this);btn001.setBounds(45, 230, 60, 30);btn002 = new JButton("2");c.add(btn002);btn002.addActionListener(this);btn002.setBounds(115, 230, 60, 30);btn003 = new JButton("3");c.add(btn003);btn003.addActionListener(this);btn003.setBounds(185, 230, 60, 30);btn004 = new JButton("4");c.add(btn004);btn004.addActionListener(this);btn004.setBounds(255, 230, 60, 30);btn005 = new JButton("5");c.add(btn005);btn005.addActionListener(this);btn005.setBounds(325, 230, 65, 30);btn006 = new JButton("6");c.add(btn006);btn006.addActionListener(this);btn006.setBounds(45, 270, 60, 30);btn007 = new JButton("7");c.add(btn007);btn007.addActionListener(this);btn007.setBounds(115, 270, 60, 30);btn008 = new JButton("8");c.add(btn008);btn008.addActionListener(this);btn008.setBounds(185, 270, 60, 30);btn009 = new JButton("9");c.add(btn009);btn009.addActionListener(this);btn009.setBounds(255, 270, 60, 30);btn000 = new JButton("0");c.add(btn000);btn000.addActionListener(this);btn000.setBounds(325, 270, 65, 30); btnsure1 = new JButton("确定");。

java上机编程题 金融

java上机编程题 金融

以下是几个金融领域的 Java 上机编程题,供参考:
1. 编写一个程序,计算银行存款利息。

输入存款金额、年利率和存款期限,输出存款期限到期后的总利息。

2. 编写一个程序,模拟股票价格变化。

输入某股票的初始价格和每天的涨跌幅度,输出每天的股票价格直到价格变为0或翻倍。

3. 编写一个程序,实现简单的财务管理。

输入收入和支出的明细,计算当前的余额,并输出余额和所有明细的信息。

4. 编写一个程序,实现简单的期权定价。

输入股票价格、行权价格、无风险利率、期权到期时间和期权类型(看涨或看跌),输出期权的估值。

5. 编写一个程序,实现简单的投资组合优化。

输入多个资产的预期收益率和方差,以及投资组合的约束条件(例如总权重为1),输出最优的投资组合。

以上是一些常见的金融领域的 Java 上机编程题,如果您需要更多的例题或有特定的问题,请具体说明。

Java编程

Java编程

/*创建银行账户类SavingAccount,用静态变量存储年利率,用私有实例变量存储存款额。

提供计算年利息的方法(即余额乘以年利率)和计算月利息的方法(即年利息/12)的方法。

编写一个测试程序测试该类,建立SavingAccount的对象saver,存款额是3000,设置年利率是3%,计算并显示saver的存款额、年利息和月利息。

要求:(1)SavingAccount类要有构造方法,用于对存款额赋初值。

(2)SavingAccount类要有显示存款额的方法。

*/class SavingAccount{private double saving;public static double intrest;SavingAccount(double saving){this.saving=saving;}public double yearIntrest(){return saving*intrest;}public double monthIntrest(){return yearIntrest()/12;}public String toString(){return "存款余额是"+saving;}}public class ch5_1{public static void main(String []args){SavingAccount sa=new SavingAccount(3000);SavingAccount.intrest=0.03;System.out.println(sa);System.out.println("年利息是:"+sa.yearIntrest());System.out.println("月利息是:"+sa.monthIntrest());}}/*第2题:编写程序,模拟银行账户功能。

要求如下:编写银行类Account,该类具备以下属性和方法:属性:账号、储户姓名、存款余额、最小余额。

相关主题
  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

import java.awt.Color;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Graphics;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Toolkit;
import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.text.NumberFormat;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane; import javax.swing.JTextArea;
import javax.swing.JTextField;
import javax.swing.border.LineBorder;
/**
* @author守护
*
*/
public class Interest extends JFrame {
private JLabel a1;
private JLabel a2;
private JLabel a3;
private JTextField b1;
private JTextField b2;
private JTextField b3;
private JButton c1;
private JButton c2;
private JButton c3;
private JTextArea text;
public Interest()
{
creatComponents() ; layoutComponents(); registerHandlers();
setTitle("复利存款应用程序(守护)"); setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); pack();
}
private void creatComponents()
{
a1=new JLabel("本金");
a1.setFont(new Font("宋体",Font.BOLD,18));
a2=new JLabel("年利率");
a2.setFont(new Font("宋体",Font.BOLD,18));
a3=new JLabel("年数");
a3.setFont(new Font("宋体",Font.BOLD,18));
b1=new JTextField(10);
b2=new JTextField(10);
b3=new JTextField(10);
c1=new JButton("计算");
c1.setFont(new Font("宋体",Font.BOLD,15));
c3=new JButton("诺诺");
c3.setBackground(Color.GREEN);
c3.setToolTipText("LOVE YOU FOREVER");
c3.setBorder(new LineBorder(Color.RED,3));
c3.setFont(new Font("宋体",Font.BOLD,20)); c3.setForeground(Color.YELLOW);
c2=new JButton("清除");
c2.setFont(new Font("宋体",Font.BOLD,15)); text=new JTextArea();
}
private void layoutComponents()
{
//Container c=this.getContentPane(); setLayout(new FlowLayout());
JPanel panel1=new JPanel();
panel1.add(a1);
panel1.add(b1);
JPanel panel2=new JPanel();
panel2.add(a2);
panel2.add(b2);
JPanel panel3=new JPanel();
panel3.add(a3);
panel3.add(b3);
JPanel panel4=new JPanel();
panel4.add(c1);
panel4.add(c3);
panel4.add(c2);
JPanel leftpanel=new JPanel(new GridLayout(4,1));
leftpanel.add(panel1);
leftpanel.add(panel2);
leftpanel.add(panel3);
leftpanel.add(panel4);
JScrollPane panel5=new JScrollPane(text);
panel5.setPreferredSize(new Dimension(200,150));
add(leftpanel);
add(panel5);
}
private void registerHandlers()
{
c1ActionEventHander hander1=new c1ActionEventHander();
c1.addActionListener(hander1);
c2ActionEventHander hander2=new c2ActionEventHander();
c2.addActionListener(hander2);
c3ActionEventHander hander3=new c3ActionEventHander();
c3.addActionListener(hander3);
}
private class c1ActionEventHander implements ActionListener {
public void actionPerformed(ActionEvent e)
{
double principal;
double amount;
double rate;
int n;
NumberFormat
currencyformatter=NumberFormat.getCurrencyInstance();
String output="年"+"/t"+"复利存款"+"/n";
int year =1;
principal=Double.parseDouble(b1.getText());
rate=Double.parseDouble(b2.getText());
n=Integer.parseInt(b3.getText());
while(year<=n)
{
amount=principal*Math.pow(1+rate,year);
output+=String.valueOf(year)+"\t"+currencyformatter.format(a mount)+"\n";
year=year+1;
}
text.setText(output);
}
}
private class c2ActionEventHander implements ActionListener {
public void actionPerformed(ActionEvent e)
{
b1.setText("");
b2.setText("");
b3.setText("");
text.setText("");
}
}
private class c3ActionEventHander implements ActionListener {
public void actionPerformed(ActionEvent e)
{
b1.setText("");
b2.setText("");
b3.setText("");
text.setText("守护love 傻姑娘"); }
}
public static void main(String[] args) {
Interest frame=new Interest();
frame.setVisible(true);
frame.setSize(450,200);
frame.setResizable(false);
}
}。

相关文档
最新文档