hey guys so i been asked to write this rock paper scissors program. and it should loop until whenever either player or computer reaches 3 wins. however, it only loops twice for some reason here's my code and thanks in advance.
import java.util.Scanner; import javax.swing.JOptionPane; class RockPaperScissors { public static void main(String args[]) { int compWin = 0; int userWin = 0; Scanner input = new Scanner(System.in); JOptionPane.showMessageDialog(null, "ROCK - PAPER - SCISSORS" + " \n Whoever wins more than two times is the winner!"); do { int totalRound = 1; String s = JOptionPane.showInputDialog(null, "Computer's Move: X" + "\n Your Move: ", "Scissor-Rock-Paper", JOptionPane.QUESTION_MESSAGE); int player = Integer.parseInt(s); if ( player < 3) { int computer = (int)(Math.random() * 3); if (computer == player) { JOptionPane.showMessageDialog(null, "it's a tie make your move again"); } else if ( computer == 0 && player == 2 ) { JOptionPane.showMessageDialog(null, "scissor0 cuts paper2 computer wins"); compWin++; } else if ( computer == 0 && player == 1) { JOptionPane.showMessageDialog(null, " rock1 beats scissor0 player wins"); userWin++; } else if ( computer == 1 && player == 0) { JOptionPane.showMessageDialog(null, " rock1 beats scissor0 computer wins"); compWin++; } else if ( computer == 1 && player == 2) { JOptionPane.showMessageDialog(null, " paper2 beats rock1 player wins"); userWin++; } else if ( computer == 2 && player == 0) { JOptionPane.showMessageDialog(null, " scissor0 cuts paper2 player wins"); userWin++; } else if ( computer == 2 && player == 1) { JOptionPane.showMessageDialog(null, "paper2 beats rock1 computer wins"); compWin++; } totalRound++; } else { JOptionPane.showMessageDialog(null, "Sorry! No such choice. Please enter (0) for Scissor, (1) for Rock, and (2) for paper"); } JOptionPane.showInputDialog(null, "Computer's Move: X" + "\n Your Move: ", "Scissor-Rock-Paper", JOptionPane.QUESTION_MESSAGE); }while (compWin > 2 || userWin > 2); } }