It's probably something stupid, but I just can't see it as the same idea is working in the same code. Basically, it's a Rock, Paper, Scissors games - it ends when either the computer or user gets to 3, by declaring an int variable and incrementing it in the case of a win for either party. Loop then exits when get totalCompWin < 3 or totalUserWin < 3, I want the loop to exit as soon as it gets to 3 (so starts at 0, +1, +1 and next +1 exits loop. It exits fine once the user wins 3 times, but won't ever exit for the computer variable. Like I said, it's probably something stupid.
import java.util.Scanner; public class rockPaperSci { public static void main(String args[]) { // 0 is rock, 1 is scissors, 2 is paper Scanner input = new Scanner(System.in); int userInput = 0, compGo, totalUserWin = 0, totalCompWin = 0; double random; do{ System.out.print("Enter 0 for Rock, 1 for Scissors, 2 for Paper: "); userInput = input.nextInt(); //computer input random = Math.random() * 100; compGo = (int) random; compGo = compGo % 3; if (compGo == userInput) System.out.print("Draw. Go again.\n"); else if (userInput == 0 && compGo == 1) { System.out.print("Rock beats Scissors! User wins!\n"); totalUserWin++; } else if (userInput == 1 && compGo == 2) { System.out.print("Scissors beat Paper! User wins!\n"); totalUserWin++; } else if (userInput == 2 && compGo == 0) { System.out.print("Paper beats Rock! User wins!\n"); totalUserWin++; } else if (userInput >= 3) { System.out.print("Please read. Enter between 0 and 2, not 3 or higher!!!"); } //for all non user wins, Computer wins. No need to show results really - can be added later on. After displaying Computers Wins, TotalCompWin gets incremented. else { System.out.print("Computer Wins! \n"); totalCompWin++; } }while (totalCompWin < 3 || totalUserWin < 3); //tried the below inside and outside while loop if (totalUserWin == 3) System.out.print("User Wins!!!!"); else if (totalCompWin == 3) System.out.print("Rise of the Machines!!!! Computer whooped your candy ass!"); //end } }