how can i loop a whole code and make it repeat until the user wants to stop.

boolean stop = false;

while (!stop) {

//code to be repeated 


//ask user if he/she wants to stop
if yes stop = true;
}

This forum is full of examples on how to read input from the keyboard.
Do a little search.

Also check the classes:

Scanner
BufferedReader

This forum is full of examples on how to read input from the keyboard.
Do a little search.

Also check the classes:

Scanner
BufferedReader

so would i do something like this:

Scanner keyboard = new Scanner(System.in);

System.out.println("Enter true to repeat game.");
boolean true = keyboard.next();

if this is right would i do this in the while loop or outside of it
thanks for your help

Comments
Still no code tags

so would i do something like this:

Scanner keyboard = new Scanner(System.in);

System.out.println("Enter true to repeat game.");
boolean true = keyboard.next();

if this is right would i do this in the while loop or outside of it
thanks for your help

I don't believe that this is correct: boolean true = keyboard.next(); because you can't give your variables names like: true which is a keyword for java.

I was thinking something like:

System.out.println("Enter N to stop game.");
String input = keyboard.next();

if (input.equals("N")) {
  stop = true;
}

But since you have marked the thread solved you probably have already figured it out

This question has already been answered. Start a new discussion instead.