-2
嘿,對不起格式不好。我在一個java類,不知道如何將銀行帳戶數據轉換成一個顯示值的方法,如果有人可以幫助,這將是偉大的!我不明白如何調用相同的方法,但通過不同的銀行帳戶我想我可以直接調用showData(a);但這不起作用。請幫忙!!顯示數據方法
`/**
* Write a description of class TestBankAccount here.
*
* @author (your name)
* @version (a version number or a date)
*/
import java.util.Scanner;
public class TestBankAccount
{
public static void main(String[] args)
{
int AccountNumber;
String name;
double balance;
double NewBalance;
bankAccount newAccount = new bankAccount();
newAccount = getData(newAccount);
bankAccount newAccount2 = new bankAccount();
newAccount2 = getData(newAccount);
bankAccount newAccount3 = new bankAccount();
newAccount3 = getData(newAccount);
bankAccount newAccount4 = new bankAccount();
}
public static bankAccount getData(bankAccount s)
{
int AccountNum;
String ownerName;
double AccountBalance;
Scanner stan = new Scanner(System.in);
System.out.print("Enter Account Number ");
AccountNum = stan.nextInt();
stan.nextLine();
System.out.print("Enter owner name ");
ownerName = stan.nextLine();
System.out.println("Enter Account Balance: ");
AccountBalance = stan.nextDouble();
s.setAccountNumber(AccountNum);
s.setName(ownerName);
s.setBalance(AccountBalance);
s.setNewBalance(AccountBalance);
return s;
}
public static void showData(bankAccount a)
{
System.out.println("The account number is: ");
System.out.println(a.getAccountNumber());
System.out.println("The owner name is: ");
System.out.println(a.getName());
System.out.println("The balance is: ");
System.out.println(a.getNewBalance());
System.out.println(a.explanation());
}
}`
請您標點技能的工作。你爲什麼不好格式化,你可以格式化這個帖子?關於你的問題 - 只要仔細看看你的代碼... – home 2014-11-21 16:17:13
我一直在看我的代碼只是請幫助帶領我走向我需要做的事情我很困難。關於格式,我只是非常不熟悉網站,需要幫助很快抱歉! – 2014-11-21 16:23:53