java银行存取代码下载 java银行存取代码下载不了

使用JAVA编写一个简单的银行存取款程序package com.lw.thread;
/*
银行账户类Account(不能透支) ,
包含账号id(10~16位数字) , 密码password(6位数字),户主姓名name,余额balence
*/
public class Account {
private String id;
private int password;
private String name;
private double balence;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public int getPassword() {
return password;
}
public void setPassword(int password) {
this.password = password;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public double getBalence() {
return balence;
}
public void setBalence(double balence) {
this.balence = balence;
}
/*
* 默认构造账户信息为:1111111111111111,666666 , 钱三多,888888.88 。
*/
public Account() {
super();
this.id = "1111111111111111";
this.password = 666666;
this.name = "钱三多";
this.balence = 888888.88;
}
/*
* 另一个构造方法带4个参数分别初始化4个属性(带数据有效性验证) 。
*/
public Account(String id, int password, String name, double balence) {
this.id = id;
this.password = password;
this.name = name;
this.balence = balence;
}
/*
* 查询余额
*/
public static double selectMoney(Account account) {
return account.getBalence();
}
/*
* 存钱
*/
public static String setMoney(Account account, double balence) {
if (balence0) {
return "存钱失败,请正确放入!";
}
double d = balenceaccount.getBalence();
account.setBalence(d);
return "您存入了"balence"元,现账户余额为 "d;
}
/*
* 取钱
*/
public static String getMoney(Account account, double balence) {
double d = account.getBalence();
if (balenced) {
return "您的余额不足!";
}
account.setBalence(d - balence);
return "您取出了"balence"元 , 现账户余额为 "account.getBalence();
}
}
java银行存取款代码问题,做得好我就追加悬赏您好,
创建状态
使用new运算符创建一个线程后 , 该线程仅仅是一个空对象,系统没有分配资源,称该线程处于创建状态(new thread)
可运行状态
使用start()方法启动一个线程后 , 系统为该线程分配了除CPU外的所需资源,使该线程处于可运行状态(Runnable)
运行中状态
Java运行系统通过调度选中一个Runnable的线程 , 使其占有CPU并转为运行中状态(Running) 。此时 , 系统真正执行线程的run()方法 。
package pack.java.thread.atm;
/**
* 账户类;
* @author Administrator
*
*/
public class Account {
private String name;//用户名;
private int value;//账户余额;
/**
* 存入金额;
* @param monery
*/
public void putMonery(int monery){
this.value = https://www.04ip.com/post/this.valuemonery;
}
/**
* 取出金额;
* @param monery
* @return 金额;
*/
public int getMonery(int monery){
//判断是否账户余额是否大于 要取出的钱;
if(this.valuemonery ){
this.value = https://www.04ip.com/post/this.value - monery;
}else{
monery = this.value;//账户余额不够时,则取出,所有的账户余额的金额.
this.value = https://www.04ip.com/post/0;
}
//返回取出的钱;
return monery;
}
/**
* 查询余额;
* @return 返回账户余额;
*/
public int search(){
return this.value;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getValue() {
return value;
}
public void setValue(int value) {
this.value = https://www.04ip.com/post/value;
}
}
用java编的银行账户系统代码package pack.money.persistent;import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;import pack.money.entity.Client;
import pack.money.entity.ClientMessage;
public class ClientPersistent {
//private static int a=0;
private static String t,b;//t是passwordb是clinetname
private static ClientPersistent sp;
public static ClientPersistent getClientPersistent() {
if (sp == null) {
sp = new ClientPersistent();
}
return sp;
}
private ClientMessage getClientMessage(ResultSet rs) throws Exception{
ClientMessage student=new ClientMessage();
student.setMoney(rs.getFloat("money"));
student.setType(rs.getString("type"));
student.setClientName(rs.getString("ClientName"));
student.setTransactionID(rs.getInt("TransactionID"));
return student;
}
public Client login(Connection con,String ClientName,String password) throws Exception{
String sql="select balance,password,ClientName from Client where ClientName=? and password=?";
PreparedStatement ps=con.prepareStatement(sql);
ps.setString(1, ClientName);
ps.setString(2, password);
ResultSet rs=ps.executeQuery();
t=password;
b=ClientName;
System.out.println(t);
System.out.println(b);
if(rs.next()){
Client client=new Client();
client.setClientName(rs.getString("ClientName"));
client.setPassword(rs.getString("password"));
return client;}
throw new Exception("Can not login, the accountID or password has error. ");
} public void save(Connection con ,String money)throws Exception
{// a;
String s="save";
float g=Float.parseFloat(money);
String sql="update Client set balance=balance ? where ClientName=?";
String sql1="insert into ATMTransaction(ClientName,Type,money)values(?,?,?) ";
PreparedStatement ps=con.prepareStatement(sql);
PreparedStatement ps1=con.prepareStatement(sql1);
ps.setFloat(1, g);
ps.setString(2,b);
//ps1.setInt(1,a);
ps1.setString(1,b);
ps1.setString(2,s);
ps1.setFloat(3,g);
ps.executeUpdate();
ps1.executeUpdate();
}
public void withDraw (Connection con ,String money)throws Exception
{//a;
String s="WithDraw";
float x=Float.parseFloat(money);
String sql="update Client set balance=balance-? where ClientName=?";
String sql1="insert into ATMTransaction(ClientName,Type,money) values(?,?,?)";
PreparedStatement ps=con.prepareStatement(sql);
PreparedStatement ps1=con.prepareStatement(sql1);
ps.setFloat(1, x);
ps.setString(2,b);
//ps1.setInt(1,a);
ps1.setString(1,b);
ps1.setString(2,s);
ps1.setFloat(3,x);
ps.executeUpdate();
ps1.executeUpdate();
}
public String changePassword(Connection con, String OldPassWord,String newPassWord1,String newPassWord2)
throws Exception
{
if(t.equals(OldPassWord))
{
if(newPassWord1.equals(newPassWord2))
{
String sql="update Client set password=? where ClientName=?";
PreparedStatement ps=con.prepareStatement(sql);
ps.setString(1, newPassWord1);
ps.setString(2,b);
ps.executeUpdate();
String j="dsfasdf";
return j;
}
else
{System.out.print("确认密码错误!");brreturn null;}
}
else
{return null;
}
}
public ArrayListClientMessage disPlayAll(Connection con ) throws Exception
{
String sql="select * from ATMTransaction where ClientName=? ";
PreparedStatement ps=con.prepareStatement(sql);
ps.setString(1,b);
System.out.println(b "****b****");
ResultSet rs=ps.executeQuery();
ArrayListClientMessage message=new ArrayListClientMessage();
while(rs.next()){
message.add(this.getClientMessage(rs));
}
return message;
}
public float showBalance(Connection con ) throws Exception
{
String sql="select balance from Client where ClientName=?";
PreparedStatement ps=con.prepareStatement(sql);
ps.setString(1, b);
ResultSet rs=ps.executeQuery();
if(rs.next())
{
float s;
s=rs.getFloat("balance");
return s;
}
else return 0 ;
}
}
JAVA 简单银行系统的代码import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class AccountDemo {
public static double MONEY = 0;// 初始化金额是100元 。
public static void main(String[] args) {
final String USER_NAME = "zhangsan";// 用户名
final String PASSWORD = "123456";// 密码
while (true) {
System.out.print("请输入用户名:");
String user_name = getString();
System.out.print("请输入密码:");
String password = getString();
if (user_name != nulluser_name.equals(USER_NAME)
password != nullpassword.equals(PASSWORD)) {
System.out.println("登陆成功!你要干什么?");
while (true) {
System.out.println("1:存款");
System.out.println("2:取款");
System.out.println("3:查询余额");
System.out.println("q:退出程序");
System.out.print("请选择:");
String userIn = getString();
int in = 0;
if (userIn != nulluserIn.equals("1")) {
in = Integer.parseInt(userIn);
} else if (userIn != nulluserIn.equals("2")) {
in = Integer.parseInt(userIn);
} else if (userIn != nulluserIn.equals("3")) {
in = Integer.parseInt(userIn);
【java银行存取代码下载 java银行存取代码下载不了】} else if (userIn != null
userIn.trim().toUpperCase().equals("Q")) {
in = 4;
} else {
System.out.println("你输入的指令不正确!请重新输入 。");
continue;
}
switch (in) {
case 1:
double add_money = 0;
while (true) {
System.out.print("请输入你要存入的金额:");
try {
add_money = Double.parseDouble(getString());
} catch (Exception e) {
System.out.println("金额输入不正确!");
continue;
}
break;
}
MONEY= add_money;
System.out.println("存入的金额是"add_money
"\r\n请选择你要的操作:");
break;
case 2:
double money = 0;
while (true) {
System.out.print("请输入你要取出的金额:");
try {
money = Double.parseDouble(getString());
} catch (Exception e) {
System.out.println("金额输入不正确!");
continue;
}
if (moneyMONEY) {
System.out.println("取出的金额大于现有存款,请重新输入要取出的金额!");
continue;
}
break;
}
MONEY -= money;
System.out.println("取出的金额是"money"\r\n请选择你要的操作:");
break;
case 3:
System.out.println("你的余额是:"MONEY"\r\n请选择你要的操作:");
break;
case 4:
System.out.println("程序退出!");
return;
}
}
} else {
System.out.println("错误:用户名与密码不匹配!\r\n");
System.out.println("按任意键:重新输入用户名和密码 。");
System.out.println("q:退出程序 。");
System.out.print("请选择:");
String in = getString();
if (in.trim().toUpperCase().equals("Q")) {
break;
}
}
}
}
public static String getString() {
String str = null;
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
try {
str = br.readLine();
} catch (IOException e) {
e.printStackTrace();
}
return str;
}
}
java银行存取代码下载的介绍就聊到这里吧,感谢你花时间阅读本站内容,更多关于java银行存取代码下载不了、java银行存取代码下载的信息别忘了在本站进行查找喔 。

    推荐阅读