public class Transation { private String tranType; // 定义交易类型
private String tranAccount; // 定义交易账号
private double tranAmount; // 定义交易金额 public Transation(String tranType, String tranAccount, double tranAmount) { // 定义构造函数
this.tranAccount = tranAccount;
this.tranAmount = tranAmount;
this.tranType = tranType;
} //定义得到和设置属性的方法
public String getTranType() {
return tranType;
} public void setTranType(String tranType) {
this.tranType = tranType;
} public String getTranAccount() {
return tranAccount;
} public void setTranAccount(String tranAccount) {
this.tranAccount = tranAccount;
} public double getTranAmount() {
return tranAmount;
} public void setTranAmount(double tranAmount) {
this.tranAmount = tranAmount;
}
}
② 用java语言编写一个小型的银行系统代码
privateintbalance=0;
privateStringusername="A";
privateStringpassword="B";
publicvoidbank(){
Scannerscan=newScanner(System.in);
Stringtemp;
while(true){
System.out.println("输入账号:");
if(scan.hasNext()){
temp=scan.next();
if(temp.equals(username)){
break;
}else{
System.out.println("输入错误");
}
}
}
while(true){
System.out.println("输入密码:");
if(scan.hasNext()){
temp=scan.next();
if(temp.equals(password)){
break;
}else{
System.out.println("输入错误");
}
}
}
System.out.println("登录成功");
while(true){
System.out.println("输入操作:");
if(scan.hasNext()){
temp=scan.next();
switch(temp){
case"存款":
intx=0;
while(true){
System.out.println("输入存款金额:");
if(scan.hasNextInt()){
x=scan.nextInt();
break;
}else{
System.out.println("输入错误");
scan.next();
}
}
balance+=x;
break;
case"取款":
inty=0;
while(true){
System.out.println("输入取款金额:");
if(scan.hasNextInt()){
y=scan.nextInt();
if(balance<y){
System.out.println("余额不足");
continue;
}
break;
}else{
System.out.println("输入错误");
scan.next();
}
}
balance-=y;
break;
case"余额":
System.out.println("余额:"+balance);
break;
case"终止":
System.exit(0);
default:
System.out.println("未知操作");
}
}
}
③ Java语言程序设计:设计银行账户类,属性包括账号、储户名称、开户时间、身份证号码、存款余额等
写个例子吧,既没有分,又不付费。。。。真的是。。
public class account{
public static int serviceNum;
private String account;
private String password;
......
public String getAccount(){
return this.account;
}
public void setAccount(String account){
this.account = account;
}
public String getPassword(){
return this.password;
}
public void setPassword(String password){
this.password = password
}
public Account(String account,String password){
this.account = account;
this.password = password;
}
public Account(String account){
this.account = account;
}
@overrite
public String toString(){
return this.account + "-" + this.password;
}
}
④ Java课程设计,模拟银行存取业务,按照这个流程图去做,其实最主要的是求画圈的部分怎么写和它的方法。
请点击输入图片描述
package com.greatwall.business.controller;
import java.math.BigDecimal;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
/**
* @author xysddjyt
* @since 2020/6/16 15:06
*/
public class BankTest {
public static void main(String[] args) {
Scanner scan = new Scanner(System.in);
// 余额(单位:分)
Long BALANCE = 10000000L;
// 卡号
String card = "001";
// 密码
String password = "123456";
String inputCard = new String();
String inputPassword = new String();
String quit = new String();
while (true) {
System.out.println(" 欢迎来到网上银行办理存取款业务!");
System.out.println("请输入银行卡号和银行卡密码进行登录!");
while (true) {
System.out.print("请输入银行卡号(按q退出): ");
inputCard = scan.nextLine();
quit = inputCard;
if (inputCard.equals("q")) {
break;
}
if (!inputCard.equals(card)) {
System.out.print("您输入银行卡号不正确,请重新输入 ");
continue;
}
break;
}
if (quit.equals("q")) {
continue;
}
while (true) {
System.out.print("请输入银行卡密码(按q退出): ");
inputPassword = scan.nextLine();
quit = inputPassword;
if (inputPassword.equals("q")) {
break;
}
if (!inputPassword.equals(password)) {
System.out.print("您输入银行卡密码不正确,请重新输入 ");
continue;
}
break;
}
if (quit.equals("q")) {
continue;
}
System.out.print("登录成功,当前登录的账户名:" + inputCard);
String type = "4";
while (!type.equals("0")) {
System.out.print(" 您当前的余额为:" + money(BALANCE) + "元");
System.out.print(" 请选择操作类型。(存款:1;取款:2 ;余额:3;退出:0) ");
type = scan.nextLine();
switch (type) {
case "1": {
System.out.print("请输入您的存款金额(元):");
String chageNumber = scan.nextLine();
if (!isPositiveInteger(chageNumber)) {
System.out.print("请输入正确的存款金额!");
continue;
}
BALANCE = Long.valueOf(chageNumber) * 100 + BALANCE;
continue;
}
case "2": {
System.out.print("请输入您的取款金额(元):");
String chageNumber = scan.nextLine();
if (!isPositiveInteger(chageNumber)) {
System.out.print("请输入正确取款金额!");
continue;
}
BALANCE = BALANCE - Long.valueOf(chageNumber) * 100;
continue;
}
case "3": {
System.out.print("您当前的余额为:" + money(BALANCE) + "元 ");
continue;
}
default: {
continue;
}
}
}
}
}
private static boolean isMatch(String regex, String orginal) {
if (orginal == null || orginal.trim().equals("")) {
return false;
}
Pattern pattern = Pattern.compile(regex);
Matcher isNum = pattern.matcher(orginal);
return isNum.matches();
}
// 判断数据是否为正整数
public static boolean isPositiveInteger(String orginal) {
return isMatch("^\+{0,1}[1-9]\d*", orginal);
}
// 分转元,转换为bigDecimal在toString
public static String money(Long money) {
return BigDecimal.valueOf(money).divide(new BigDecimal(100)).toString();
}
}
⑤ 用Java编写简单的银行系统
这个有点复杂,说点简单的思路
1.首先要建立数据库表,保存数据需要保存到表中专
create table Account(
账号属ID
密码
有多少钱
)
如果要保存流水记录的话,还的建张表保存记录
2.java
账号类
class Account{
账号ID
密码
有多少钱
}
一个操作类
class Test{
开户,登录,存款,取款,查询余额,修改密码
各写一个方法
}
⑥ 用JAVA编程设计一个银行账户类,其中包括以下内容,并用字符界面模拟存款和取款过程。
import java.util.Scanner;
public class ZH {
private String zh;//账户
private String password;//密码
private String openTime;//开户时间
private String sfz;//身份证号
private double je;//存款金额
public String getZh() {
return zh;
}
public void setZh(String zh) {
this.zh = zh;
}
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
public String getOpenTime() {
return openTime;
}
public void setOpenTime(String openTime) {
this.openTime = openTime;
}
public String getSfz() {
return sfz;
}
public void setSfz(String sfz) {
this.sfz = sfz;
}
public double getJe() {
return je;
}
public void setJe(double je) {
this.je = je;
}
//存款方法
public void ck(double je){
this.je=this.je+je;//存入的金额加上原有的金额
}
//取款方法
public void qk(double je){
if(je>this.je){//取款金额大于余额
System.out.println("存款余额不足");
}else{
this.je=this.je-je;//原有的金额减去取出的金额
}
}
public static void main(String[] args) {
ZH zh = new ZH();//初始化一个账户信息
zh.setJe(10000.0);//向zh账户添加余额
zh.setOpenTime("2013.12.3");//向zh账户添加开发时间
zh.setPassword("123456");//向zh账户添加密码
zh.setSfz("123456789");//向zh账户添加身份证
zh.setZh("zhangsan");//向zh账户添加账号
System.out.println("欢迎光临模拟银行");
Scanner scan = new Scanner(System.in);
int count=0;//记录输入错误的次数
while(1==1){//循环
System.out.println("请输入账号");
String zhm=scan.next();
System.out.println("请输入密码");
String mm=scan.next();
if(zhm.equals(zh.getZh()) && mm.equals(zh.getPassword())){//输入的信息与zh账户信息的密码和账号一致
while(1==1){
System.out.println("当前余额为:"+zh.getJe()+"元。请选择操作:1.存款;2.取款;3.退出(只能输入数字)");
String cz=scan.next();
switch (Integer.parseInt(cz)) {
case 1:
System.out.println("请输入存款金额(输入小数)");
double ckje=scan.nextDouble();
zh.ck(ckje);
System.out.println("实施存款:"+ckje+"元,当前余额为"+zh.getJe()+"元");
break;
case 2:
System.out.println("请输入取款金额(输入小数)");
double qkje=scan.nextDouble();
zh.qk(qkje);
System.out.println("实施取款:"+qkje+"元,当前余额为"+zh.getJe()+"元");
break;
case 3:
break;
default:
System.out.println("暂无此功能");//输入1或者2、3以外的操作
break;
}
if("3".equals(cz)){
break;
}
}
System.out.println("退出操作");
break;
}else{
if(count>=3){
System.out.println("已输入错误三次,账号被锁");
break;//结束循环
}else{
System.out.println("账号或密码错误,请重新输入");
count++;//错误一次count+1
continue;//进入下次循环
}
}
}
}
}
⑦ JAVA 简单银行系统的代码
这个不简单,
从分析设计,到编码实现,
都是需要精力和时间花费的体现,
建议还是自己亲自走一遍吧,
能学点东西。
⑧ 用java实现银行排队程序,要求模拟银行的业务排队系统,要有界面,实现完成的排队和叫号
import java.awt.Color;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JTextField;
public class BankWaiting extends JFrame implements ActionListener {
int total = 0, now = 0;
boolean is1Ready = false, is2Ready = false, is3Ready = false;
int call1, call2, call3;
JFrame jf;
JLabel jr, jl, jl1, j2, jl2, j3, jl3;
JTextField jr4;
JButton jb, jb1, jb2, j1;
JButton workBut1, workBut2, workBut3;
JPanel jp, jp1, jp2;
public BankWaiting() {
setLayout(null);
jf = new JFrame("银行叫号程序");// 窗体
jr = new JLabel("请**号到*号窗口办理业务");
jr.setBounds(300, 10, 800, 50);
jr.setForeground(Color.red);
j1 = new JButton("取号");
j1.addActionListener(this);
jr4 = new JTextField("欢迎");
jr4.setEditable(false);
ButtonGroup bg = new ButtonGroup();
bg.add(j1);
jp = new JPanel();
jl = new JLabel("一号窗口");
jl1 = new JLabel("一号窗口,欢迎你!");
jb = new JButton("下一位");
workBut1 = new JButton("开始办理");
workBut1.addActionListener(this);
jb.addActionListener(this);
jp.setBackground(Color.pink);
jp.setSize(200, 80);// 大小
jp.setLocation(20, 120); // 位置
jf.setLayout(null);
jp1 = new JPanel();
j2 = new JLabel("二号窗口");
jl2 = new JLabel("二号窗口,欢迎你!");
jb1 = new JButton("下一位");
workBut2 = new JButton("开始办理");
jb1.addActionListener(this);
workBut2.addActionListener(this);
jp1.setBackground(Color.pink);
jp1.setSize(200, 80);// 大小
jp1.setLocation(250, 120); // 位置
jf.setLayout(null);
jp2 = new JPanel();
j3 = new JLabel("三号窗口");
jl3 = new JLabel("三号窗口,欢迎你!");
jb2 = new JButton("下一位");
workBut3 = new JButton("开始办理");
workBut3.addActionListener(this);
jb2.addActionListener(this);
jp2.setBackground(Color.pink);
jp2.setSize(200, 80);// 大小
jp2.setLocation(500, 120); // 位置
jf.setLayout(null);
jf.add(jp);
jf.add(jp1);
jf.add(jp2);
jf.add(jr);
jp.add(jl);
jp.add(jl1);
jp.add(jb);
jp.add(workBut1);
jp1.add(j2);
jp1.add(jl2);
jp1.add(jb1);
jp1.add(workBut2);
jp2.add(j3);
jp2.add(jl3);
jp2.add(jb2);
jp2.add(workBut3);
jf.add(j1);
jf.add(jr4);
j1.setBounds(550, 300, 60, 30);
jr4.setBounds(300, 300, 200, 40);
jf.setSize(800, 600);
jf.setVisible(true);
jf.addWindowListener(new WindowAdapter() {
public void windowClosing(WindowEvent e) {
System.exit(0);
}
});
}
public void actionPerformed(ActionEvent e) {
String s = "";
if (e.getSource() == j1) {
s = "第" + (++total) + "号,前面还有" + (total - now - 1) + "位顾客!";
jr4.setText(s);
}
if (e.getSource() == jb) {
if (this.hasCustomers()) {
s = "请" + (++now) + "号顾客到一号窗口办理";
call1 = now;
jl1.setText(s);
jr.setText(s);
is1Ready = true;
} else {
s = "当前已经没有顾客了";
jl1.setText(s);
is1Ready = false;
}
} else if (e.getSource() == jb1) {
if (this.hasCustomers()) {
s = "请" + (++now) + "号顾客到二号窗口办理";
call2 = now;
jl2.setText(s);
jr.setText(s);
is2Ready = true;
} else {
s = "当前已经没有顾客了";
jl2.setText(s);
is2Ready = false;
}
} else if (e.getSource() == jb2) {
if (this.hasCustomers()) {
s = "请" + (++now) + "号顾客到三号窗口办理";
call3 = now;
jl3.setText(s);
jr.setText(s);
is3Ready = true;
} else {
s = "当前已经没有顾客了";
jl3.setText(s);
is3Ready = false;
}
}
if (e.getSource() == workBut1) {
if (is1Ready) {
s = call1 + "号顾客正在办理业务。。。";
jl1.setText(s);
is1Ready = false;
}
} else if (e.getSource() == workBut2) {
if (is2Ready) {
s = call2 + "号顾客正在办理业务。。。";
jl2.setText(s);
is2Ready = false;
}
} else if (e.getSource() == workBut3) {
if (is3Ready) {
s = call3 + "号顾客正在办理业务。。。";
jl3.setText(s);
is3Ready = false;
}
}
}
public boolean hasCustomers() {
if (now < total) {
return true;
} else {
return false;
}
}
public static void main(String[] args) {
new BankWaiting();
}
}