Enter the result of 4 matches played between team A and team B. Determine and report the number of matches won by each and the winner of more matches if they did not get the same results.
This time my problem is that if I enter the same number of matches won (for both teams) it tells me that Team B is the one with the most amount of teams won, when I would have to say a draw.
int partidos = 5;
int equipoA = 0;
int equipoB = 0;
int partidosGanados1 = 0;
int partidosGanados2 = 0;
Scanner teclado = new Scanner(System.in);
for (int i = 1; i < partidos; i++) {
System.out.println(i + "Ingrese goles del equipo A : ");
equipoA = teclado.nextInt();
System.out.println(i + "Ingrese goles del equipo B : ");
equipoB = teclado.nextInt();
if (equipoA > equipoB) {
partidosGanados1++;
System.out.println("Gana equipo A .");
}
if (equipoB > equipoA) {
partidosGanados2++;
System.out.println("Gana equipo B .");
}
}
if (equipoA != equipoB) {
if (equipoA > equipoB)
{
System.out.println("El ganador de mas partidos es el equipo A. ");
}
else {
System.out.println("El ganador de mas partidos es el equipo B. ");
}
System.out.println("No hay empate.");
}
else if (equipoA == equipoB ) {
System.out.println("Empate.");
}
System.out.println("Cantidad de partidos ganados por el equipo A : " + partidosGanados1);
System.out.println("Cantidad de partidos ganados por el equipo B : " + partidosGanados2);