Idk what title is appropiate for this lol but someone can help me?
My question's inside the "//"
Code :
switch (TransactionType){
case 'w':
EndingBalance = InitialBalance - TransactionAmount;
NumberOfWithdrawals++;
System.out.println("Account Number: " + AccountNum);
System.out.println("Beggining Balance: $" + InitialBalance);
System.out.println("Ending Balance: " + EndingBalance);
System.out.println("Total amount withdrawn: $" + TransactionAmount);
System.out.println("Number of withdrawals: " + NumberOfWithdrawals);
System.out.println("Withdraw again? (1/0): ");
again = in.nextInt();
while (!found)
if (again == 0)
{
System.out.println("Transaction done!");
found = true;
}
else if (again == 1)
{
double finaal;
NumberOfWithdrawals++;
System.out.println("Enter amount to be withdrawn: ");
withdrawn = in.nextDouble();
System.out.println("Account number: " + AccountNum);
finaal = EndingBalance - withdrawn;
System.out.println("Beggining Balance: " + EndingBalance); //What i wanted to happen is to change this into a new variable
//so it'll be the InitialBalance on the next loop(If the user would like to
//withdraw again).
System.out.println("Ending Balance: " + finaal);
System.out.println("Number of Withdrawals: " + NumberOfWithdrawals);
System.out.println("Withdraw again?: (1/0) ");
again = in.nextInt();
found = false;
}
Re: Idk what title is appropiate for this lol but someone can help me?
Quote:
change this into a new variable so it'll be the InitialBalance on the next loop(I
Define a variable to hold the value and then assign it to the desired variable on the next loop.
Does the posted code show the loop you are talking about?
You should use {}s with ALL while and if statments to enclose the code that goes with them.
It's hard to see the end of the while statement in the posted code because the code is not enclosed in {}s
Also statements inside of loops should be indented 3-4 spaces so you can easily see the logic.
Also posted at http://www.java-forums.org/new-java/...n-help-me.html