public?static?void?main(String[]?args)?{
創(chuàng)新互聯(lián)建站堅持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:成都網(wǎng)站制作、成都做網(wǎng)站、企業(yè)官網(wǎng)、英文網(wǎng)站、手機端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時代的番禺網(wǎng)站設(shè)計、移動媒體設(shè)計的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
String?realPwd?=?"111111";
Integer?errorCount?=?0;
Integer?account;
Scanner?sc?=? new?Scanner(System.in);
while(true){
System.out.print("請輸入密碼:");
String?pwd?=?sc.next();
if(!pwd.equals(realPwd)){
errorCount++;
System.out.println("第"+errorCount+"次輸入密碼不正確");
if(errorCount=3){
System.out.println("密碼錯誤,請取卡");
break;
}
}else{
while(true){
System.out.print("請輸入取款金額:");
account?=?sc.nextInt();
if(account1000?||?account0){
System.out.println("取款金額最低0元,最高1000元");
}else?if(account%100!=0){
System.out.println("只有100的紙幣");
}else{
System.out.println("取款金額"+account+"元");
System.out.println("交易完成,請取卡");
break;
}
}
break;
}
}
}
import javax.swing.JOptionPane;
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;
}
//查看開戶時間
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, "請放入鈔票!");
JOptionPane.showMessageDialog(null,"開戶賬號為"+user.getaccount()+"\n"+user.getName()+"\n開戶時間為"+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, "請取出鈔票!");
user.get(b);
JOptionPane.showMessageDialog(null,"開戶賬號為"+user.getaccount()+"\n"+user.getName()+"\n開戶時間為"+user.data()+"\n您的余額為"+user.balance());
}
}
s=JOptionPane.showInputDialog("您好,存款選擇1,取款選擇2,退出選擇0");
x=Integer.parseInt(s);
}
}
}
public class Card {
public String type; //卡的類型
public String cardCode; //卡號
public double money; //錢
/**
* 重寫toString()方法
*/
public String toString(){
return "卡的類型:"+type+"\t卡號:"+cardCode+"\t余額:"+money;
}
}public class Person {
Card card;
/**
* 構(gòu)造方法,一般用來初始化信息
* 此方法是創(chuàng)建對象時自動調(diào)用的
*
*/
public Person(){
card=new Card();
card.type="招商銀行";
card.money=1000D;
}
/**
*
* @param money 你要取的錢
* @return 返回的是取到的錢
*/
public double getMoney(double money){
if( (card.money-money) =0){
card.money=card.money-money;//從卡中減去要取的錢,并重新改變卡中的余額
return money;
}else{
System.out.println("余額不足:請存款!");
return 0;
}
}
/**
* 存款
* @param money
*/
public void setMoney(double money){
if(money=0){
System.out.println("不能為0!");
}else
card.money=card.money+money;
}
/**
* 這個方法是輸出客戶卡的信息
*/
public void print(){
System.out.println(card);
}
}public class Text {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Person p=new Person();
p.card.cardCode="111100022222";
p.setMoney(1000);
double money=p.getMoney(2000);
System.out.println(p.card);
}
}
/** * @author admin * 該程序的功能為實現(xiàn)模擬銀行ATM自動取款機提款,查詢等功能. */ import Java.io.*; /*該類為實現(xiàn)客戶信息及部分功能*/ class Account { private String code =null; //信用卡號 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; } } /**********實現(xiàn)具體取款機功能*********/ 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模擬自動取款機程序.\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("請輸入您的信用卡號:"); card=br.readLine(); System.out.println("請輸入您的密碼:"); pwd=br.readLine(); if(!isRight(card,pwd)) { System.out.println("您的卡號或密碼輸入有誤."); counter ; } else SysOpter(); }while(counter3); Lock_Sys(); } 回復(fù)獲取全部
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("密碼錯誤,請取卡");
break;
}
System.out.println("請輸入你的密碼");
String password = sc.next();
if(password.equals("111111")){
Boolean moneyflag = true;
while(moneyflag){
System.out.println("請輸入金額");
int number = sc.nextInt();
if(number = 0 number = 1000 number % 100 == 0){
System.out.println("用戶取了" + number + "元。交易完成");
moneyflag = false;
}else{
System.out.println("請重新輸入金額");
}
}
break;
}else{
continue;
}
}
}
}
package demo;
import java.util.Scanner;
public class Test3 {
public static void main(String[] args) {
Scanner scanner =new Scanner(System.in);
int cnt=3;
String username = null;
String password = null;
double money = 1000;
String targetName = "admin33";
double targetMoney = 1000;
while(true){
if(username!=nullpassword!=null){
if("admin".equals(username) "123".equals(password)){
System.out.println("歡迎光臨");
while(true){
System.out.println("請選擇您的操作 1 取錢 2 存錢 3 轉(zhuǎn)賬 4 查詢 5 退出 ");
int n = scanner.nextInt();
if(n==1){//取錢
System.out.println("請輸入金額");
int getter = scanner.nextInt();
if(getter=0){
if(getter=5000){
if(getter=money){
money-=getter;
}else{
System.out.println("余額不足");
}
}else{
System.out.println("單筆只能取5000及以下");
}
}else{
System.out.println("銀行不到給");
}
}else if(n==2){//存錢
System.out.println("請輸入金額");
int save = scanner.nextInt();
if(save=0){
money+=save;
}
}else if(n==3){//轉(zhuǎn)賬
System.out.println("請輸入目標賬戶");
String target = scanner.next();
if(target.equals(targetName)){
System.out.println("請輸入金額");
int getter = scanner.nextInt();
if(getter=0){
if(getter=5000){
if(getter=money){
money-=getter;
targetMoney+=getter;
}else{
System.out.println("余額不足");
}
}else{
System.out.println("單筆只能取5000及以下");
}
}else{
System.out.println("銀行不到給");
}
}
}else if(n==4){//查詢
System.out.println(money);
}else if(n==5){//退出
System.exit(0);
}else{
System.out.println("沒有該項服務(wù)");
}
}
}else{
cnt--;
System.out.println("輸入錯誤,您還有"+cnt+"次機會");
username=null;
password=null;
if(cnt=0){
System.out.println("對不起,您的賬號被凍結(jié),請到最近的營業(yè)廳解除凍結(jié)");
System.exit(0);
}
}
}else{
System.out.println("請輸入您的賬號");
username = scanner.next();
System.out.println("請輸入您的密碼");
password = scanner.next();
}
}
}
}
分享名稱:javaatm取錢代碼,javaATM取款代碼
轉(zhuǎn)載來于:http://www.rwnh.cn/article46/phpieg.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)、網(wǎng)站收錄、標簽優(yōu)化、云服務(wù)器、Google、軟件開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)