Skip to content
Advertisement

A method that I wrote with a scanner class doesn’t seem to end

I wrote a method in order to get the choice of the user for the size of a grid. However, my code doesn’t seem to work after executing the method, as it continues to run without end after I type in the response to console (if it matters, I am on repl.it). What is the issue with the code that prevents it from ending?

JavaScript

Advertisement

Answer

In the first If check in the while loop Change

JavaScript

to

JavaScript

since u do not want the user to input size twice. Your code should work fine now.

Let me know if anything isn’t clear so I can modify and elaborate further

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement