账户java代码 java账号

求JAVA实现用户登录界面代码?

你要先学会截图哦,你发的看不清楚,重新写了一个你参考参考!

创新互联公司专注于安康企业网站建设,成都响应式网站建设公司,成都做商城网站。安康网站建设公司,为安康等地区提供建站服务。全流程按需求定制设计,专业设计,全程项目跟踪,创新互联公司专业和态度为您提供的服务

import java.awt.GridLayout;

import javax.swing.ButtonGroup;

import javax.swing.JButton;

import javax.swing.JComboBox;

import javax.swing.JFrame;

import javax.swing.JLabel;

import javax.swing.JPanel;

import javax.swing.JRadioButton;

import javax.swing.JTextField;

public class Day30A extends JFrame {

private static final long serialVersionUID = 1L;

private JLabel labelName,labelId,labelPass,labelMoney,labelSelect,labelCar;

private JComboBoxString jcb;

private JPanel jp1,jp2,jp3,jp4,jp5,jp6,jp7;

private ButtonGroup btg;

private JRadioButton jr1,jr2;

Day30A(){

this.setTitle("注册账户");

this.setLayout(new GridLayout(7,1));

this.setSize(300,280);

this.setLocationRelativeTo(null);

this.setDefaultCloseOperation(EXIT_ON_CLOSE);

init();

this.setVisible(true);

}

private void init() {

String str="卡片类型1,卡片类型2,卡片类型3,卡片类型4,卡片类型5";

jcb=new JComboBox(str.split(","));

labelId=new JLabel("账号: ");

labelName=new JLabel("姓名: ");

labelPass=new JLabel("密码: ");

labelMoney=new JLabel("开户金额:");

labelSelect=new JLabel("存款类型:");

labelCar=new JLabel("卡片类型:");

addFun1();

addFun2();

}

private void addFun2() {

this.add(jp1);

this.add(jp2);

this.add(jp3);

this.add(jp4);

this.add(jp5);

this.add(jp6);

this.add(jp7);

}

private void addFun1() {

jp1=new JPanel();

jp1.add(labelId);

jp1.add(new JTextField(15));

jp2=new JPanel();

jp2.add(labelName);

jp2.add(new JTextField(15));

jp3=new JPanel();

jp3.add(labelPass);

jp3.add(new JTextField(15));

jp4=new JPanel();

jp4.add(labelMoney);

jp4.add(new JTextField(13));

jp5=new JPanel();

jp5.add(labelSelect);

btg=new ButtonGroup();

jr1=new JRadioButton("定期");

jr2=new JRadioButton("活期",true);

btg.add(jr1);

btg.add(jr2);

jp5.add(jr1);

jp5.add(jr2);

jp6=new JPanel();

jp6.add(labelCar);

jp6.add(jcb);

jp7=new JPanel();

jp7.add(new JButton("确定"));

jp7.add(new JButton("取消"));

}

public static void main(String[] args) {

new Day30A();

}

}

用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是password b是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("确认密码错误!");br return 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.util.*;

public class Account

{

private String id; //帐号

private static double money; //总额

private double annualiInterestRate; //当前年利率

private Date riqi; //开户日期

public Account()

{

}

//设置器和访问器

public String getId() {

return id;

}

public void setId(String id) {

this.id = id;

}

public double getAnnualiInterestRate() {

return annualiInterestRate;

}

public void setAnnualiInterestRate(double annualiInterestRate) {

this.annualiInterestRate = annualiInterestRate;

}

public Date getRiqi() {

return riqi;

}

public void setRiqi(Date riqi) {

this.riqi = riqi;

}

//几个方法

public double getMonthlyInterestRate() //返回月利率

{

return annualiInterestRate/12;

}

public void withDraw(double temp) //从账户提取特定数额的款

{

money=money-temp; //取款后的余额

}

public void deposit(double info) //向帐户中存入特定数额的款

{

money=money+info; //存款后的余额

}

public void show()

{

System.out.println("该帐户余额为:"+money+",月利率为:"+this.getMonthlyInterestRate()+",开户日期是:"+new Date());

}

public static void main(String[] args)

{

Account acc=new Account();

acc.setId("1122");

acc.money=20000.0;

acc.setAnnualiInterestRate(0.045);

acc.withDraw(2500.0);

acc.deposit(3000.0);

acc.show();

}

}

java 创建账户类,定义存钱取钱,查询余额方法,并自定义两个异常

main方法不对啊

少了public

public static void main(String[] args) {}

这次是对的


网站题目:账户java代码 java账号
标题网址:http://bzwzjz.com/article/hepjgo.html

其他资讯

Copyright © 2007-2020 广东宝晨空调科技有限公司 All Rights Reserved 粤ICP备2022107769号
友情链接: 成都网站设计 手机网站建设 成都营销网站制作 网站制作 成都网站建设 成都网站设计 成都网站设计 成都网站制作 网站设计 移动网站建设 盐亭网站设计 高端网站设计 成都h5网站建设 重庆网站制作 成都网站设计制作公司 泸州网站建设 营销型网站建设 重庆企业网站建设 成都企业网站建设 成都网站建设推广 成都网站设计 高端品牌网站建设