I was wondering if it was possible to go from the end of the if
(deposit.equals("y")) part of my code back to the start of class. I was
also wondering if it was possible to get the balance variable from a
file and then after the program ended update that file with the new
balance (btw the code isnt broken up like this, since this has line
margins, ConText doesnt)
import static java.lang.System.*;
import java.util.Scanner;
class bank {
public static void main(String args[]) {
double balance;
balance = 0.00;
out.println("Your current balance is $" + balance + ".");
out.println("Do you want to make a deposit? (y\\n)");
Scanner depositScanner = new Scanner(System.in);
String deposit = depositScanner.next();
if (deposit.equals("y")) {
out.println("Please enter your deposit
amount:");
Scanner depositamountScanner = new
Scanner(System.in);
double depositamount =
depositamountScanner.nextDouble();
balance = balance + depositamount;
out.println("Your new deposit amount is: $" +
balance + ".");
}
else {
("Please come again.")
}
}
}
SMC - 15 Jun 2005 07:42 GMT
> I was wondering if it was possible to go from the end of the if
> (deposit.equals("y")) part of my code back to the start of class. I was
[quoted text clipped - 32 lines]
> }
> }
Put a loop around it, eg
boolean finished = false;
do {
// body
if (deposit.equals("y"){
// ...
}
else{
// ...
finished = true;
}
}while (!finished)

Signature
Sean
There's no place like 127.0.0.1