java中ATM转账代码 java中的atm编程

用Java实现ATM的转账,取款,改密码,查询功能, 要代码!

 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("输入您要存入的数额");

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, "你所输入的存款数额有误!");

}

else{

str=JOptionPane.showInputDialog("输入您要取出的数额");

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

}

}

}

用java编写的ATM机源代码

/** * @author admin * 该程序的功能为实现模拟银行ATM自动取款机提款,查询等功能. */ import Java.io.*; /*该类为实现客户信息及部分功能*/ 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; } /*得到剩余的钱的数目*/ protected void set_Balance(double mon) { money -= mon; } } /**********实现具体取款机功能*********/ 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.密码设置." "\n" " 4.退出系统." "\n"); } /**********登陆系统**********/ 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(); } 回复获取全部

如何用Java代码编写银行转账

public interface ITransfer{ /* * 银行内部转账,从转出账号中扣除转账金额,给转入账号增加转账金额,需要保证以上两个操作 * 要么同时成功,要么同时失败 * fromAccountId 转出账号 * outAccountId 转入账号 * amount 转账金额 */ public void transferInner(String fromAccountId,String outAccountId,BigDecimal amount); /* * 外部转账-转出,从转出账号中扣除转账金额 * fromAccoutnId 转出账号 * amount 转账金额 */ public void transferOut(String fromAccountId,String outAccountId,BigDecimal amount); /* * 外部转账-转入,从转入账号中增加转账金额 * toAccoutnId 转出账号 * amount 转账金额 */ public void transerIn(String toAccountId,BigDecimal amount); } public interface ITransfer{ /* * 银行内部转账,从转出账号中扣除转账金额,给转入账号增加转账金额,需要保证以上两个操作 * 要么同时成功,要么同时失败 * fromAccountId 转出账号 * outAccountId 转入账号 * amount 转账金额 */ public void transferInner(String fromAccountId,String outAccountId,BigDecimal amount); /* * 外部转账-转出,从转出账号中扣除转账金额 * fromAccoutnId 转出账号 * amount 转账金额 */ public void transferOut(String fromAccountId,String outAccountId,BigDecimal amount); /* * 外部转账-转入,从转入账号中增加转账金额 * toAccoutnId 转出账号 * amount 转账金额 */ public void transerIn(String toAccountId,BigDecimal amount); }

java atm机代码

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;

}

}

}

}


当前名称:java中ATM转账代码 java中的atm编程
URL分享:http://myzitong.com/article/dodoiig.html