This is a continuation of a previous question to which i was unable to get an answer. The problem is when i try end the program using the System.exit(0) method with a switch statement and a "End" keyword and case, the code no longer runs as it should, only every second integer input is now read by the computer. Here is my method that is no longer working:
public static int[] ourGuess() {
int[] guessed = new int[4];
Scanner scan = new Scanner(System.in);
System.out.println("Take your guess:");
switch (scan.nextLine()) {
case "End":
System.exit(0);
break;
}
guess = scan.nextInt();
int mod = 10;
int div = 1;
for (int i = 3; i >= 0; i--) {
int num = (guess % mod) / div;
guessed[i] = num;
div = div * 10;
mod = mod * 10;
}
return guessed;
}
The class is a java implementation of the mastermind game. Thanks for all the help!