import javax.swing.JOptionPane;
創(chuàng)新互聯(lián)堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:網(wǎng)站設(shè)計(jì)制作、成都網(wǎng)站建設(shè)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的夏縣網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
public class Account
{
private String name;
private String account;
private String data;
private String ID;
private double balance;
public Account(String name,double balance,String data,String ID)
{
this.name = name;
this.balance = balance;
this.data=data;
this.ID=ID;
}
public String getaccount()
{
this.account=String.valueOf((int)(Math.random()*100000)+1);
return account;
}
public String getdata()
{
return data;
}
public String getID()
{
return ID;
}
public String getName()
{
return name;
}
public double getbalance()
{
return balance;
}
//查看賬戶余額
public double balance()
{
return balance;
}
//查看開戶時(shí)間
public String data()
{
return data;
}
//存款操作
public boolean put(double value)
{
if (value0)
{
this.balance += value;
return true;
}
return false;
}
//取款操作
public double get(double value)
{
if (value0)
{
if (value=this.balance)
this.balance -= value;
else
{
value = this.balance;
this.balance = 0;
}
return value;
}
return 0;
}
public static void main(String args[]){
Account user=new Account("張三",2000,"2011/05/23","362329198906234225");
String str;
int b;
String s=JOptionPane.showInputDialog("您好,存款選擇1,取款選擇2,退出選擇0");
int x=Integer.parseInt(s);
while(x!=0){
if(x==1)
{
str=JOptionPane.showInputDialog("輸入您要存入的數(shù)額");
b=Integer.parseInt(str);
if( user.put(b)){
JOptionPane.showMessageDialog(null, "請(qǐng)放入鈔票!");
JOptionPane.showMessageDialog(null,"開戶賬號(hào)為"+user.getaccount()+"\n"+user.getName()+"\n開戶時(shí)間為"+user.data()+"\n您的余額為"+user.balance());
}
else
JOptionPane.showMessageDialog(null, "你所輸入的存款數(shù)額有誤!");
}
else{
str=JOptionPane.showInputDialog("輸入您要取出的數(shù)額");
b=Integer.parseInt(str);
if(buser.balance())
{
JOptionPane.showMessageDialog(null, "余額不足");
}
else
{
JOptionPane.showMessageDialog(null, "請(qǐng)取出鈔票!");
user.get(b);
JOptionPane.showMessageDialog(null,"開戶賬號(hào)為"+user.getaccount()+"\n"+user.getName()+"\n開戶時(shí)間為"+user.data()+"\n您的余額為"+user.balance());
}
}
s=JOptionPane.showInputDialog("您好,存款選擇1,取款選擇2,退出選擇0");
x=Integer.parseInt(s);
}
}
}
/** * @author admin * 該程序的功能為實(shí)現(xiàn)模擬銀行ATM自動(dòng)取款機(jī)提款,查詢等功能. */ 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í)現(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.密碼設(shè)置." "\n" " 4.退出系統(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 SysOpter(); }while(counter3); Lock_Sys(); } 回復(fù)獲取全部
public interface ITransfer{ /* * 銀行內(nèi)部轉(zhuǎn)賬,從轉(zhuǎn)出賬號(hào)中扣除轉(zhuǎn)賬金額,給轉(zhuǎn)入賬號(hào)增加轉(zhuǎn)賬金額,需要保證以上兩個(gè)操作 * 要么同時(shí)成功,要么同時(shí)失敗 * fromAccountId 轉(zhuǎn)出賬號(hào) * outAccountId 轉(zhuǎn)入賬號(hào) * amount 轉(zhuǎn)賬金額 */ public void transferInner(String fromAccountId,String outAccountId,BigDecimal amount); /* * 外部轉(zhuǎn)賬-轉(zhuǎn)出,從轉(zhuǎn)出賬號(hào)中扣除轉(zhuǎn)賬金額 * fromAccoutnId 轉(zhuǎn)出賬號(hào) * amount 轉(zhuǎn)賬金額 */ public void transferOut(String fromAccountId,String outAccountId,BigDecimal amount); /* * 外部轉(zhuǎn)賬-轉(zhuǎn)入,從轉(zhuǎn)入賬號(hào)中增加轉(zhuǎn)賬金額 * toAccoutnId 轉(zhuǎn)出賬號(hào) * amount 轉(zhuǎn)賬金額 */ public void transerIn(String toAccountId,BigDecimal amount); } public interface ITransfer{ /* * 銀行內(nèi)部轉(zhuǎn)賬,從轉(zhuǎn)出賬號(hào)中扣除轉(zhuǎn)賬金額,給轉(zhuǎn)入賬號(hào)增加轉(zhuǎn)賬金額,需要保證以上兩個(gè)操作 * 要么同時(shí)成功,要么同時(shí)失敗 * fromAccountId 轉(zhuǎn)出賬號(hào) * outAccountId 轉(zhuǎn)入賬號(hào) * amount 轉(zhuǎn)賬金額 */ public void transferInner(String fromAccountId,String outAccountId,BigDecimal amount); /* * 外部轉(zhuǎn)賬-轉(zhuǎn)出,從轉(zhuǎn)出賬號(hào)中扣除轉(zhuǎn)賬金額 * fromAccoutnId 轉(zhuǎn)出賬號(hào) * amount 轉(zhuǎn)賬金額 */ public void transferOut(String fromAccountId,String outAccountId,BigDecimal amount); /* * 外部轉(zhuǎn)賬-轉(zhuǎn)入,從轉(zhuǎn)入賬號(hào)中增加轉(zhuǎn)賬金額 * toAccoutnId 轉(zhuǎn)出賬號(hào) * amount 轉(zhuǎn)賬金額 */ public void transerIn(String toAccountId,BigDecimal amount); }
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轉(zhuǎn)賬代碼 java中的atm編程
網(wǎng)頁鏈接:http://jinyejixie.com/article6/dodoiig.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供網(wǎng)站營(yíng)銷、外貿(mào)網(wǎng)站建設(shè)、網(wǎng)站維護(hù)、ChatGPT、App設(shè)計(jì)、品牌網(wǎng)站建設(shè)
聲明:本網(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)