import java.util.Scanner; //Player recognizable; Wrong number protection public class Practive{ public static void main(String[] args){ int remain = 21; Scanner scan = new Scanner(System.in); System.out.println("The rules of this game are simple. You start with 21 sticks, and two players take turns"); System.out.println("either taking one or two sticks. The player who takes the last stick loses."); System.out.println(); while (remain > 0){ System.out.println("Player A's turn: take 1 or 2 sticks. The number of reamining sticks is "+remain); int inputA = scan.nextInt(); if (inputA >=2) { inputA = 2; } else if (inputA <=1) { inputA = 1; } remain = remain-inputA; if (remain == 0){ System.out.println ("You lose."); } else { System.out.println("Player B's turn: take 1 or 2 sticks. The number of reamining sticks is "+remain); int inputB = scan.nextInt(); remain = remain-inputB; if (remain ==0){ System.out.println ("You lose"); } } if ( remain ==0){ System.out.println("Game is over"); } } } }