-3

When I run this, int x = 0 and 1 is added to x to each time it runs. The program keeps on printing out "Round 1", not allowing any time in between to input anything. This is not about reading input, it's about being able to input something without the program going crazy.

    while (!broken) {

        int pointcount = 0;

        System.out.println("Round " + x);

        Scanner jumpOption = new Scanner(System.in);

        if (jumpOption.equals("W")) {   

            pointcount += 1;

            Random rand = new Random();

            if (rand.nextInt(100) == 0) {
                broken = true;
Bob Gilmore
  • 9,708
  • 13
  • 46
  • 51

2 Answers2

0

You have to actually read from the scanner with the next() method

if (jumpOption.next().equals("W")) {  
Daniel Bickler
  • 1,077
  • 14
  • 28
0

You're creating a Scanner object, but not using it for anything. To get any input from the Scanner you have to use one of its methods, like Scanner.nextLine()

Scanner myScanner = new Scanner(System.in);
// Here's where we get the actual input!
if (myScanner.nextLine().equals("Hello")
Alvin L-B
  • 468
  • 2
  • 8