Bob Bob - 9 months ago 60
Java Question

Java ignoring input occasionally

So I m new here and to programming in general I have been working on a rock paper scissors game where the user enters the letter and plays against the computer, however my input is sometimes ignored and the games restarts other times it plays on I have spent countless hours trying to figure out why this happens. Here is the code


The Method .nextInt(n) generates an Integer from and including 0 to and excluding n (in your case 0 to 2). Basically it always "ignores" your input when the Computer generates a 0 since no if condition would be true. To fix your problem and generate a number from 1 to n use .nextInt(n) + 1.