-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