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();
}
}