「java转账编程」java银行转账系统

博主:adminadmin 2022-11-23 11:28:07 73

今天给各位分享java转账编程的知识,其中也会对java银行转账系统进行解释,如果能碰巧解决你现在面临的问题,别忘了关注本站,现在开始吧!

本文目录一览:

如何用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实现账户转账问题

直接写SQL语句是不能实现事务处理的。

需要加上事务处理才能保证转账中的成功和失败的问题。

如果在转账过程中停止程序。那数据会不一致。

java需要写一个JAVA程序,模拟银行账户的查询、转账功能。

“\

T”选项卡,当输出数据显示,几乎以表格形式显示,目的是为了使数据看起来整齐点。

“\

n”换行,其他行显示下一个(...),目的是换行字符或字符串,使用System.out.println();效果是一样的。

实现A B两个用户之间的转账,我的代码不正确,求修正java语言

1. 首先为什么线程启动2次

a.start();

b.start();

2.其次System.out.println("请输入您的选择:A转账到B或者B转账到A");

这个输入的值你那里有取得

用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转账编程和java银行转账系统的介绍到此就结束了,不知道你从中找到你需要的信息了吗 ?如果你还想了解更多这方面的信息,记得收藏关注本站。

The End

发布于:2022-11-23,除非注明,否则均为首码项目网原创文章,转载请注明出处。