java怎麼創建以太坊賬號
A. java創建一個用戶類
public class User
{
private String userName;//用戶名
private String passWord;//密碼
private String name;//真名
private int age;//年齡
private String tel;//聯系方式
public User()
{
}
public User(String userName, String passWord, String name, int age, String tel) {
this.userName = userName;
this.passWord = passWord;
this.name = name;
this.age = age;
this.tel = tel;
System.out.println("注冊成功!");
}
public String getUserName() {
return userName;
}
public void setUserName(String userName) {
this.userName = userName;
}
public String getPassWord() {
return passWord;
}
public void setPassWord(String passWord) {
this.passWord = passWord;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getTel() {
return tel;
}
public void setTel(String tel) {
this.tel = tel;
}
@Override
public String toString()
{
return "用戶名:" + getUserName() + "
" + "密碼:" + getPassWord() + "
"
+"真名:" + getName() + "
" + "年齡:" + getAge() + "
"
+"聯系方式:" + getTel();
}
}
======================================================
public static void main(String[] args)
{
User user = new User();
user.setUserName("神官");
user.setPassWord("123456");
user.setName("麥依");
user.setAge(30);
user.setTel("15027777777");
System.out.println(user.toString());
user = new User("神官00","000000","=.=",18,"[email protected]");
System.out.println(user.toString());
}
B. 在java中創建兩個銀行賬號,創建賬戶所用的信息由鍵盤輸入,應該怎麼寫
publicclassBankInfo{
privateStringname;
privateintage;
privatedoublebalance=0;
BankInfo(){
}
BankInfo(Stringname,intage){
this.name=name;
this.age=age;
}
publicstaticvoidmain(Stringtarena[]){
Scannerscan=newScanner(System.in);
System.out.println("請輸入您的名字:");
Stringname=scan.next();
System.out.println("請輸入您的年齡:");
intage=scan.nextInt();
BankInfop1=newBankInfo(name,age);
System.out.println("name:"+p1.name+",age:"+p1.age);
}
}
C. 怎麼用JAVA創建銀行帳戶Account類
樓上最好加個構造函數
D. 怎樣用Java創建銀行賬號Account類,實現存款(balance)的存(deposit)、取(withdraw)和查詢(getbalan
我也剛開始學,這是我自己寫的
import java.util.Scanner;
/**
* 實現取款機功能,存款balance、存錢deposit、取withdraw、查詢getbalan
*
*/
public class Account {
public static void main(String[] args) {
double balance = 0;
double deposit = 0;
double withdraw = 0;
for (;;) {
System.out.println("請輸入數字:\t1.存錢 \t2.取錢\t3.查詢余額\n");
Scanner input = new Scanner(System.in);
String num = input.next();
double s1 = 0, s2= 0 ;
if (num.equals("1")) {
System.out.println("輸入存入金額:");
deposit = input.nextDouble();
System.out.println("存錢數目為:" + deposit);
s1 += deposit;
}
if (num.equals("2")) {
System.out.println("輸入取錢金額:");
withdraw = input.nextDouble();
System.out.println("取走金額為:" + withdraw);
s2 += withdraw;
}
if (true | num.equals("3")) {
balance += s1 - s2;
System.out.println("賬戶余額為:" + balance);
}
}
}
}
E. 怎麼用java代碼創建ftp用戶和密碼
這個取決於你的ftp伺服器,IIS,Mozila...規則不一樣
F. 如何用java創建一個登陸窗口
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JTextField;
public class Login {
public static void main(String args[]) {
LoginFrm frame = new LoginFrm();
}
}
class LoginFrm extends JFrame implements ActionListener{
JLabel nameLabel=new JLabel("用戶名:");
JLabel pwdLabel=new JLabel("密碼:");
JTextField name=new JTextField(10), password=new JTextField(10);
JButton butnSure=new JButton("確定");
JButton butnCancel=new JButton("取消");
public LoginFrm() {
super("登陸");
setBounds(500, 200, 280, 220);
setVisible(true);
setLayout(null);
nameLabel.setBounds(45, 20, 100, 25);
add(nameLabel);
add(name);
name.setBounds(105, 20, 110, 25);
add(pwdLabel);
pwdLabel.setBounds(45, 60, 100, 25);
add(password);
password.setBounds(105, 60, 110, 25);
add(butnSure);
butnSure.setBounds(45, 100, 80, 25);
add(butnCancel);
butnCancel.setBounds(135, 100, 80, 25);
butnSure.addActionListener(this);
butnCancel.addActionListener(this);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
validate();//刷新
}
public void actionPerformed(ActionEvent e) {
if (e.getSource() ==butnSure){
System.out.println("用戶名:"+name.getText());
System.out.println("密碼:"+name.getText());
if("wyjwsj".equals(name.getText().trim())&&"12345".equals(password.getText().trim())){
this.dispose();
new MainFrm("用戶界面",name.getText().trim(),password.getText().trim());
}else {
JOptionPane.showMessageDialog(this, "用戶名或密碼不對!");
}
}else if(e.getSource()==butnCancel){
System.exit(1);
}
}
class MainFrm extends JFrame{
private JLabel info;
public MainFrm(String s,String name,String password) {
super(s);
setBounds(400, 200, 500, 400);
setLayout(new FlowLayout());
info=new JLabel("登陸成功,用戶名:"+name+",密碼:"+password);
add(info);
setVisible(true);
setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
validate();
}
}
}
G. 用java 創建一個用戶名
分析需求
輸入 :JohnSmith
輸出:JSmith
John是常用人名.Smith是姓氏. 中間使用空白分開
主要考查的字元串的操作
參考代碼
importjava.util.Scanner;
publicclassNameDemo{
publicstaticvoidmain(String[]args){
System.out.println("請輸入名字:");
Scannersc=newScanner(System.in);
Stringname=sc.nextLine().trim();
String[]ss=name.split("\s+");//s表示用空白切割字元串,+表示1個或者多個空白
Stringming=ss[0];//名
Stringxing=ss[1];//姓
System.out.println(ming.charAt(0)+xing);//ming.charAt(0)表示取得該字元串的第一個字元
}
}
運行測試
請輸入名字:
JohnSmith
JSmith
H. JAVA 編程創建Account 類模擬銀行賬戶。
我幫你一共寫了四個類,一個賬戶Account類,兩個賬戶類的子類(信用卡賬戶CreditCardAccount類和借記卡DebitCardAccount類),另外再加上一個演示透支效果測試Test類。 代碼貼在下面:
/**
* 賬戶類。
*
* @author CodingMouse
* @version 1.0
*/
public abstract class Account { protected String accountNumber; // 賬號
protected double overage; // 余額
protected double annualInterestRate; // 年利率
/**
* 參數化構造器方法。
*
* 用於開戶。
* @param accountNumber 預設賬號
* @param overage 初始余額
* @param annualInterestRate 預設年利率
*/
public Account(String accountNumber, double overage, double annualInterestRate) {
super();
// 設定賬號。
this.accountNumber = accountNumber;
// 設定初始余額,至少為零。
this.overage = overage >= 0 ? overage : 0;
// 設定年利率,至少為零。
this.annualInterestRate = annualInterestRate >= 0 ? annualInterestRate : 0;
}
/**
* 查詢賬號。
* @return 返回賬號。
*/
public String getAccountNumber() {
return this.accountNumber;
}
/**
* 設置賬號。
* @param accountNumber 新賬號。
*/
public void setAccountNumber(String accountNumber) {
this.accountNumber = accountNumber;
} /**
* 查詢余額方法。
* @return 返回賬戶余額。
*/
public double getOverage() {
return this.overage;
} /**
* 存款方法。
* @param money 要存入的金額。
* @return 返回true時存款成功,否則存款失敗。
*/
public boolean depositMoney(double money) {
// 如果金額小於零,則不能存款
if (money <= 0)
return false;
// 否則將相應的金額累加到賬戶余額中
this.overage += money;
return true;
}
/**
* 取款方法。
*
* 默認不能透支。
* @param money 要取出的金額。
* @return 返回true時取款成功,否則取款失敗。
*/
public boolean drawMoney(double money) {
// 如果賬戶余額不足,則不能取款
if (this.overage < money)
return false;
// 否則從賬戶余額中扣除相應的金額
this.overage -= money;
return true;
} /**
* 查詢年利率。
* @return 返回年利率。
*/
public double getAnnualInterestRate() {
return this.annualInterestRate;
} /**
* 設置年利率。
* @param annualInterestRate 新的年利率。
*/
public void setAnnualInterestRate(double annualInterestRate) {
this.annualInterestRate = annualInterestRate;
}
}
--------------------------------------------------
/**
* 借記卡賬戶。
*
* 不能透支。
* @author CodingMouse
* @version 1.0
*/
public class DebitCardAccount extends Account { /**
* 重寫父類構造器。
* @param accountNumber 預設賬號
* @param overage 初始余額
* @param annualInterestRate 預設年利率
*/
public DebitCardAccount(String accountNumber, double overage,
double annualInterestRate) {
super(accountNumber, overage, annualInterestRate);
}}
-------------------------------------------------
/**
* 信用卡賬戶。
*
* 可以透支。
* @author CodingMouse
* @version 1.0
*/
public class CreditCardAccount extends Account { private double overdraftLimit; // 透支限度
/**
* 重載構造器。
*
* 便於構建可透支的信用卡賬戶實例。
* @param accountNumber 預設賬號
* @param overage 初始余額
* @param annualInterestRate 預設年利率
* @param overdraftLimit 透支限度
*/
public CreditCardAccount(String accountNumber, double overage,
double annualInterestRate, double overdraftLimit) {
super(accountNumber, overage, annualInterestRate);
this.overdraftLimit = overdraftLimit;
} /**
* 查詢透支限度的方法。
* @return 透支限度金額。
*/
public double getOverdraftLimit() {
return this.overdraftLimit;
} /**
* 設置透支限度的方法。
* @param overdraftLimit 新的透支限度金額。
*/
public void setOverdraftLimit(double overdraftLimit) {
// 透支限度必須為零和正數,否則為零。
this.overdraftLimit = overdraftLimit >= 0 ? overdraftLimit : 0;
} /**
* 重寫父類構造器。
* @param accountNumber 預設賬號
* @param overage 初始余額
* @param annualInterestRate 預設年利率
*/
public CreditCardAccount(String accountNumber, double overage,
double annualInterestRate) {
super(accountNumber, overage, annualInterestRate);
} /**
* 重寫父類取款方法。
*
* 將默認不能透支的取款改為可以透支的取款。
* @param money 要取出的金額。
* @return 返回true時取款成功,否則取款失敗。
*/
@Override
public boolean drawMoney(double money) {
// 如果賬戶余額 + 透支限度的總金額仍不足,則不能取款
if (this.overage + this.overdraftLimit < money)
return false;
// 否則從賬戶余額中扣除相應的金額
this.overage -= money;
return true;
}}
------------------------------------------
/**
* 測試賬戶使用。
*
* @author CodingMouse
* @version 1.0
*/
public class Test { /**
* 主程序方法。
* @param args 入口參數。
*/
public static void main(String[] args) {
// 創建一個不能透支的借記卡賬戶。
System.out.println("------------ 借記卡賬戶 ------------");
DebitCardAccount debitCardAccount = new DebitCardAccount("CHK20100117001", 100, 0.02);
// 初始余額有100元,調用並列印取90元和取120元的結果。
System.out.println("取90元的結果:" + debitCardAccount.drawMoney(90));
// 重新存入90元
debitCardAccount.depositMoney(90);
System.out.println("取120元的結果:" + debitCardAccount.drawMoney(120));
// 創建一個可以透支的信用卡賬戶。
System.out.println("------------ 信用卡賬戶 ------------");
CreditCardAccount crebitCardAccount = new CreditCardAccount("CHK20100117002", 100, 0.03, 50);
// 初始余額有100元,並且透支限度為50元,調用並列印取90元、取120元和取160元的結果。
System.out.println("取90元的結果:" + crebitCardAccount.drawMoney(90));
// 重新存入90元
crebitCardAccount.depositMoney(90);
System.out.println("取120元的結果:" + crebitCardAccount.drawMoney(120));
// 重新存入120元
crebitCardAccount.depositMoney(120);
System.out.println("取160元的結果:" + crebitCardAccount.drawMoney(160));
}
}
-------------------------------------- 在我機器上的測試列印結果為: ------------ 借記卡賬戶 ------------
取90元的結果:true
取120元的結果:false
------------ 信用卡賬戶 ------------
取90元的結果:true
取120元的結果:true
取160元的結果:false ----------------------------------------- 這個題目只是簡單考查了下封裝、繼承、多態三大面向對象特性,我提供的代碼僅作參考。 如果你懶得復制,想要程序源代碼文件或有不明白的地方,可以發郵件到我QQ郵箱,我再回給你。
I. Java怎麼創建一個方法
publicStringgetfileName(Stringpath){
returnpath;
}
例如這個
J. java如何用數組新建用戶名和密碼
importjava.util.ArrayList;
importjava.util.Scanner;
/**
*
*@authoryoung
*
*/
classPeople{
privateStringname;
privateStringpassword;
privatedoubleheight;
privatedoubletz;
privateStringblood;
publicPeople(Stringname,Stringpassword,doubleheight,doubletz,
Stringblood){
super();
this.name=name;
this.password=password;
this.height=height;
this.tz=tz;
this.blood=blood;
}
publicstaticArrayList<People>addPeople(){
ArrayList<People>al=newArrayList<People>();
Scannersc=newScanner(System.in);
System.out.print("請輸入姓名:");
Stringn=sc.next();
System.out.print("請輸入密碼:");
Stringpa=sc.next();
System.out.print("請輸入身高:");
doubleh=sc.nextDouble();
System.out.print("請輸入體重:");
doublet=sc.nextDouble();
System.out.print("請輸入血型:");
Stringb=sc.next();
Peoplep=newPeople(n,pa,h,t,b);
al.add(p);
System.out.println("添加用戶成功!");
returnal;
}
publicstaticintcd(){
inti;
System.out.println("*********************");
System.out.println("*******菜單********");
System.out.println("*****1添加*******");
System.out.println("*****2查找*******");
System.out.println("*****0退出*******");
System.out.println("*********************");
Scannersc=newScanner(System.in);
System.out.print("請輸入你的選擇:");
i=sc.nextInt();
returni;
}
publicstaticvoidfind(ArrayList<People>al){
Scannersc=newScanner(System.in);
System.out.print("請輸入查找姓名:");
Stringn=sc.next();
System.out.print("請輸入查找密碼:");
Stringpa=sc.next();
for(Peoplep:al){
if(p.name.equals(n)&&(p.password.equals(pa))){
System.out.println("姓名:"+p.name+"身高:"+p.height+"體重:"+p.tz+"血型:"+p.blood);
}else{
System.out.println("對不起!查無此人.");
}
}
}
publicstaticvoidmain(String[]args){
inti;
ArrayList<People>al=newArrayList<People>();
i=cd();
while(i!=0){
switch(i){
case1:
al=addPeople();
break;
case2:
find(al);
break;
case0:
System.out.println("退出系統!");
break;
default:
break;
}
i=cd();
}
}
}