をスキップしながらピンと私はそれを入力するものは、残りの部分をスキップし、私は別のトランザクションが欲しい場合は私に尋ねる。doループは、身体が最初に正常に動作しますが、それはそれは私が代わりに名前を入力することはできません必要がありますように、それがループするとき、それは最初の二つの文を印刷し、それを入力するように直進しながら、ループは私のDOで文
私は部分的に提出された配列オブジェクトを持っています。オブジェクト内の変数は、名前、ピン、口座番号、残高です。新しいオブジェクトを追加して残高を設定すると、新しい残高が入力されるため、前のオブジェクトの残高も同様に変更されます。私はそれが静的として宣言されてバランス変数とは何かがあると思うが、私はそれを静的にしないでください、私は "静的メソッドを静的メソッドをCustomerRecord型からwithdraw(double)にすることはできません"。 (解決済み)ありがとう。
public class BankCustomers
{
public static void main(String[] args)
//------------------------------------------------
//Part4: Find a customer record from anotherArray
//to do transaction(s) and update the record's balance
char repeat; // User control to repeat or quit
Scanner keyboard = new Scanner(System.in); //creating the scanner
String aName;
int aPin;
double aWithdraw;
double aDeposit;
do{
//Read customer information before search
System.out.println();
System.out.println("Lets make a transaction");
System.out.println("Enter customer full name");
aName = keyboard.nextLine();
System.out.println("Enter Pin");
aPin = keyboard.nextInt();
//Search an Array for equal aName and aPin
for (int i = 0; i < index; i++)
{
CustomerRecord cRecord = anotherArray[i];
if((cRecord.getName().equalsIgnoreCase(aName)) && (cRecord.getPin() ==(aPin)))
{
System.out.println(cRecord);
System.out.println("Enter Withdraw Amount");
aWithdraw = keyboard.nextDouble();
CustomerRecord.withdraw(aWithdraw);
System.out.println("Enter Deposite Amount");
aDeposit = keyboard.nextDouble();
CustomerRecord.deposit(aDeposit);
System.out.println(cRecord);
}
}
System.out.println("\nAnother Transaction? (y for yes)");
repeat = keyboard.next().charAt(0);
}while(repeat == 'y' || repeat == 'Y');
//Print the records on screen
for (int i = 0; i < index; i++)
System.out.print(anotherArray[i]);
}
注意のために同様にその
に
withdraw
をインスタンスを使用して呼び出す必要があります:あなたのコードがあまりにも長いですbefor無関係な部分を排除することによって、問題を絞り込むようにしてください。コードを投稿します。これは私たちが問題をより簡単に見つけるのを助けるだけでなく、自分で問題を見つけて理解し、解決するのに役立ちます。 – Attila私の間違い。病気はそれを世話する。 – Batman