"A very common game between 3 friends is the game of 2 or 1. In this game, the winner is different from the other two, and if all three choose equal values, the game ends in a tie. , B and C, who are playing 2 or 1: their program must show which of them is the winner or if there was a draw, read a number N that indicates the total number of games they will play and then read the values A, B, and C (integers) of each friend, consider that these values will always be 2 or 1. Show on the screen who was the winner or if there was a tie.
My code:
public static void main(String[] args) {
Scanner ler = new Scanner(System.in);
Random rand = new Random();
int numero1 = rand.nextInt(2) + 1;
int numero2 = rand.nextInt(2) + 1;
int numero3 = rand.nextInt(2) + 1;
int N;
System.out.println("DOIS OU UM!");
System.out.print("Quantas partidas serão jogadas? ");
do {
N = ler.nextInt();
System.out.println("Jogador 1: "+numero1);
System.out.println("Jogador 2: "+numero2);
System.out.println("Jogador 3: "+numero3);
System.out.println("------------");
if (numero1 != numero2 && numero1 != numero3)
System.out.println("Jogador 1 venceu!");
else if (numero2 != numero1 && numero2 != numero3)
System.out.println("Jogador 2 venceu!");
else if (numero3 != numero1 && numero3 != numero2)
System.out.println("Jogador 3 venceu!");
else
System.out.println("O jogo terminou empatado!");
break;
} while (N > 0);
System.out.println("Fim de Jogo!");
}
The code until you are validating who is the winner and if there is a tie. The problem is in the amount I report, and it shows only once, and when I enter 0 it does not go straight to the "Game End!".