欧美一区二区三区老妇人-欧美做爰猛烈大尺度电-99久久夜色精品国产亚洲a-亚洲福利视频一区二区

javaatm代碼 javaatm機(jī)

求Java代碼 模擬簡(jiǎn)易atm機(jī)

參考了別人的代碼。略作修改,已經(jīng)很簡(jiǎn)單了:

讓客戶滿意是我們工作的目標(biāo),不斷超越客戶的期望值來自于我們對(duì)這個(gè)行業(yè)的熱愛。我們立志把好的技術(shù)通過有效、簡(jiǎn)單的方式提供給客戶,將通過不懈努力成為客戶在信息化領(lǐng)域值得信任、有價(jià)值的長期合作伙伴,公司提供的服務(wù)項(xiàng)目有:國際域名空間、網(wǎng)頁空間、營銷軟件、網(wǎng)站建設(shè)、長春網(wǎng)站維護(hù)、網(wǎng)站推廣。

InfoATM.java:

public?class?InfoATM?{

double?money?=?0;

public?InfoATM(double?cash)?{

super();

this.money?=?cash;

}

//?存款的方法

public?void?save(double?count)?{

money?+=?count;

}

//?取款的方法

public?void?draw(double?count)?{

money?-=?count;

}

public?double?getMoney()?{

return?money;

}

public?void?setMoney(double?money)?{

this.money?=?money;

}

}

TestATM.java:

import?java.awt.BorderLayout;

import?java.awt.GridLayout;

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.JTextField;

public?class?TestATM?extends?JFrame?{

private?static?final?long?serialVersionUID?=?2531222181184935595L;

//?主面板pnBasic是用來裝pnDate和標(biāo)簽文字的。

private?JPanel?pnBasic;

//?添加到主面板中的中間?pnDate面板是為了裝表單的。

private?JPanel?pnDate;

//?添加到主面板中的北邊?pnLabel面板是為了裝歡迎詞的

private?JPanel?pnLabel;

InfoATM?atm?=?new?InfoATM(0);

public?TestATM()?{

pnBasic?=?new?JPanel();

//?主面板pnBasic是用來裝pnDate和標(biāo)簽文字的。

pnDate?=?new?JPanel(new?GridLayout(2,?2));

//?pnDate面板是為了裝表單的。

pnLabel?=?new?JPanel();

JLabel?top?=?new?JLabel("歡迎來到中國銀行!");

pnLabel.add(top);

//?先將數(shù)值添加在一個(gè)容器中并設(shè)置其在容器的右邊,在將容器添加在網(wǎng)格的第一格

JPanel?jp1?=?new?JPanel();

JLabel?number?=?new?JLabel("數(shù)值:");

final?JTextField?box?=?new?JTextField(5);

jp1.add(number);

jp1.add(box);

JPanel?jp2?=?new?JPanel();

JButton?create?=?new?JButton("新建銀行賬戶");

jp2.add(create);

JButton?take?=?new?JButton("取款");

JButton?in?=?new?JButton("存款");

pnDate.add(jp1);

pnDate.add(jp2);

pnDate.add(take);

pnDate.add(in);

//?加一句下面的就好了

JPanel?jpS?=?new?JPanel();

final?JLabel?total?=?new?JLabel("您現(xiàn)在的賬戶余額是:0?元");

jpS.add(total);

pnBasic.setLayout(new?BorderLayout());

pnBasic.add(pnLabel,?BorderLayout.NORTH);

pnBasic.add(pnDate,?BorderLayout.CENTER);

pnBasic.add(jpS,?BorderLayout.SOUTH);

setContentPane(pnBasic);

setBounds(400,?250,?500,?500);

pack();

setDefaultCloseOperation(DISPOSE_ON_CLOSE);

setVisible(true);

pack();

in.addActionListener(new?ActionListener()?{

public?void?actionPerformed(ActionEvent?e)?{

if?(box.getText()?!=?null??box.getText()?!=?"")?{

try?{

double?count?=?Double.parseDouble(box.getText());

if?(count??0)?{

atm.save(count);

total.setText("您現(xiàn)在的賬戶余額是:"?+?atm.getMoney()?+?"元");

box.setText("");

}

}?catch?(Exception?e1)?{

System.out.println("您輸入的數(shù)值必須是數(shù)字");

}

}

}

});

take.addActionListener(new?ActionListener()?{

public?void?actionPerformed(ActionEvent?e)?{

if?(box.getText()?!=?null??box.getText()?!=?"")?{

try?{

double?count?=?Double.parseDouble(box.getText());

if?(count?=?0??count?=?atm.getMoney())?{

atm.draw(count);

total.setText("您現(xiàn)在的賬戶余額是:"?+?atm.getMoney()?+?"元");

box.setText("");

}?else?{

System.out.println("你的余額不足,取款失敗");

}

}?catch?(Exception?e1)?{

System.out.println("您輸入的數(shù)值必須是數(shù)字");

}

}

}

});

create.addActionListener(new?ActionListener()?{

public?void?actionPerformed(ActionEvent?e)?{

total.setText("您現(xiàn)在的賬戶余額是:0元");

atm.setMoney(0);

box.setText("");

}

});

}

public?static?void?main(String[]?args)?{

new?TestATM();

}

}

java atm機(jī)代碼

package arraylist;

import java.util.Scanner;

public class AtmDemo

{

public static void main(String[] args)

{

// TODO Auto-generated method stub

Scanner sc = new Scanner(System.in);

Boolean flag = true;

int times = 0;

while(flag){

times++;

if(times == 4){

System.out.println("密碼錯(cuò)誤,請(qǐng)取卡");

break;

}

System.out.println("請(qǐng)輸入你的密碼");

String password = sc.next();

if(password.equals("111111")){

Boolean moneyflag = true;

while(moneyflag){

System.out.println("請(qǐng)輸入金額");

int number = sc.nextInt();

if(number = 0 number = 1000 number % 100 == 0){

System.out.println("用戶取了" + number + "元。交易完成");

moneyflag = false;

}else{

System.out.println("請(qǐng)重新輸入金額");

}

}

break;

}else{

continue;

}

}

}

}

java ATM登陸循環(huán)代碼?

下面是一個(gè)簡(jiǎn)單的登錄示例:

代碼復(fù)制展示:

public class ATMLogin {

public static void main(String[] args) {

// 設(shè)置用戶名和密碼

String username = "gqk";

String password = "520";

// 最多可以登錄 3 次

for (int i = 0; i 3; i++) {

// 讀取用戶輸入的用戶名和密碼

Scanner in = new Scanner(System.in);

System.out.print("請(qǐng)輸入用戶名:");

String inputUsername = in.nextLine();

System.out.print("請(qǐng)輸入密碼:");

String inputPassword = in.nextLine();

// 檢查用戶名和密碼是否正確

if (inputUsername.equals(username) inputPassword.equals(password)) {

System.out.println("歡迎" + username + "登錄!");

break; // 登錄成功,退出循環(huán)

} else {

System.out.println("用戶名或密碼錯(cuò)誤,請(qǐng)重新輸入!");

}

}

// 如果 3 次登錄都失敗,則提示用戶

System.out.println("卡片已經(jīng)被鎖,請(qǐng)聯(lián)系客服人員!");

}

}

回答不易望請(qǐng)采納

atm機(jī)的java怎么寫啊

package demo;

import java.io.*;

/*該類為實(shí)現(xiàn)客戶信息及部分功能*/

class Account {

private String code =null; //信用卡號(hào)

private String name =null; //客戶姓名

private String password=null; //客戶密碼

private double money =0.0; //卡里金額

/********************/

public Account(String code,String name,String password,double money)

{

this.code=code;

this.name=name;

this.password=password;

this.money=money;

}

protected String get_Code() {

return code;

}

protected String get_Name() {

return name;

}

protected String get_Password() {

return password;

}

public double get_Money() {

return money;

}

/*得到剩余的錢的數(shù)目*/

protected void set_Balance(double mon) {

money -= mon;

}

/*得到剩余的錢的數(shù)目*/

protected void set_Deposit(double mon) {

money += mon;

}

}

/**********實(shí)現(xiàn)具體取款機(jī)功能*********/

class ATM {

Account act;

// private String name;

// private String pwd;

public ATM() {

act=new Account("000000","Devil","123456",50000);

}

/***********歡迎界面***********/

protected void Welcome()

{

String str="---------------------------------";

System.out.print(str+"\n"+

"歡迎使用Angel模擬自動(dòng)取款機(jī)程序.\n"+str+"\n");

System.out.print(" 1.取款."+"\n"+

" 2.存款."+"\n"+

" 3.查詢信息."+"\n"+

" 4.密碼設(shè)置."+"\n"+

" 5.退出系統(tǒng)."+"\n");

}

/**********登陸系統(tǒng)**********/

protected void Load_Sys() throws Exception

{

String card,pwd;

int counter=0;

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

do {

System.out.println("請(qǐng)輸入您的信用卡號(hào):");

card=br.readLine();

System.out.println("請(qǐng)輸入您的密碼:");

pwd=br.readLine();

if(!isRight(card,pwd))

{

System.out.println("您的卡號(hào)或密碼輸入有誤.");

counter++;

}

else

Welcome();

SysOpter();

}while(counter3);

Lock_Sys();

}

/**********系統(tǒng)操作**********/

protected void SysOpter() throws Exception

{

int num;

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

System.out.println("請(qǐng)選擇您要操作的項(xiàng)目(1-5):");

num=br.read(); //num為ASICC碼轉(zhuǎn)換的整數(shù)

switch(num) {

case 49: BetBalance(); break;

case 50: Deposit(); break;

case 51: Inqu_Info(); break;

case 52: Set_Password(); break;

case 53: Exit_Sys(); break;

}

System.exit(1);

}

/**********信息查詢

* @throws Exception **********/

protected void Inqu_Info() throws Exception {

System.out.print("---------------------\n"+

act.get_Code()+"\n"+

act.get_Name()+"\n"+

act.get_Money()+"\n"+

"-----------------------");

Welcome();

SysOpter();

}

/**********取款**********/

public void BetBalance() throws Exception

{

String str=null,str1;

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

int count=0;//取款錯(cuò)誤超過3次自動(dòng)退出

do {

System.out.println("請(qǐng)輸入您要取的數(shù)目:");

str=br.readLine();

str1=String.valueOf(act.get_Money());

System.out.println(str1);

if(Double.parseDouble(str)Double.parseDouble(str1)) {

count++;

System.out.println("超過已有的錢數(shù),請(qǐng)重新輸入您要取的數(shù)目:");

if(count=3){

System.out.println("超過已有的錢數(shù),請(qǐng)重新輸入您要取的數(shù)目:");

Exit_Sys();

}

}

else {

/*操作成功*/

act.set_Balance(Double.parseDouble(str));

System.out.println("取款成功,請(qǐng)收好您的錢.");

Welcome();

SysOpter();

}

}while(true);

}

/*******存款********/

public void Deposit() throws Exception{

String str=null;

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

do {

System.out.println("請(qǐng)輸入您要存的數(shù)目:");

str=br.readLine();

/*操作成功*/

act.set_Deposit(Double.parseDouble(str));

System.out.println("取款成功,請(qǐng)收好您的錢.");

Welcome();

SysOpter();

}while(true);

}

/**********判斷卡內(nèi)是否有錢**********/

protected boolean isBalance() {

if(act.get_Money()0) {

System.out.println("對(duì)不起,您的錢數(shù)不夠或卡已透支.");

return false;

}

return true;

}

/********卡號(hào)密碼是否正確******/

protected boolean isRight(String card,String pwd)

{

if(act.get_Code().equals(card) act.get_Password().equals(pwd))

return true;

else

return false;

}

/**********密碼修改**********/

protected void Set_Password() throws Exception

{

String pwd=null;

int counter=0;

BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

do {

System.out.println("請(qǐng)輸入舊密碼:");

pwd=br.readLine();

if(act.get_Password().equals(pwd))

{

do {

System.out.println("請(qǐng)輸入新密碼:");

String pwd1=br.readLine();

System.out.println("請(qǐng)?jiān)俅屋斎胄旅艽a:");

String pwd2=br.readLine();

if(!pwd1.equals(pwd2))

{

System.out.println("兩次輸入不一致,請(qǐng)?jiān)俅屋斎?");

}

else

{

System.out.println("密碼修改成功,請(qǐng)使用新密碼.");

Welcome();

SysOpter();

}

}while(true);

}

}while(counter3);

}

/**********鎖定機(jī)器**********/

protected void Lock_Sys() {

System.out.println("對(duì)不起,您的操作有誤,卡已被沒收.");

System.exit(1);

}

/**********結(jié)束系統(tǒng)**********/

protected void Exit_Sys() {

System.out.println("感謝您使用本系統(tǒng),歡迎下次在來,再見!");

System.exit(1);

}

}

public class Text

{

public static void main(String[] args) throws Exception

{

ATM atm=new ATM();

atm.Load_Sys();

// atm.Exit_Sys();

}

}

卡號(hào):00000 密碼123456 默認(rèn)50000金額。簡(jiǎn)單版本的存取款。

網(wǎng)頁名稱:javaatm代碼 javaatm機(jī)
新聞來源:http://chinadenli.net/article8/hgdjip.html

成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供自適應(yīng)網(wǎng)站、網(wǎng)站收錄域名注冊(cè)、品牌網(wǎng)站設(shè)計(jì)、搜索引擎優(yōu)化、靜態(tài)網(wǎng)站

廣告

聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請(qǐng)盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場(chǎng),如需處理請(qǐng)聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)

成都網(wǎng)頁設(shè)計(jì)公司