0
I’m having a workout for college but I’m lost in my logic and how to solve it. I have to collect the game results and set the score for each result. the winner takes 3 points, a draw guarantees 1 point and the defeat of no point.
I know I don’t have much yet but I wrote it here:
Note: The teacher asks you to use only two-dimensional string arrays!
(Define a two-dimensional array of Strings Representing the Results of Matches. and a four-element array of ints Representing Scores of Teams of Germany, Ireland,Poland and Scotland (in this order). The program Calculates total score for each team (3 points for a win, 1 for a draw, 0 for a defeat), puts them into the array and then prints it)
Obs2: this English only because I study and live in Poland and the course and in English.
public class Jogos {
public static void main(String[] args) {
String [][] resultados = new String[12][4];
resultados [0][0]="Alemanha";
resultados [0][1]=2;
resultados [0][2]="Escocia";
resultados [0][3]=1;
resultados [1][0]="Polonia";
resultados [1][1]=2;
resultados [1][2]="Alemanha";
resultados [1][3]=0;
resultados [2][0]="Alemanha";
resultados [2][1]=1;
resultados [2][2]="Irlanda";
resultados [2][3]=1;
resultados [3][0]="Polonia";
resultados [3][1]=2;
resultados [3][2]="Escocia";
resultados [3][3]=2;
resultados [4][0]="Escocia";
resultados [4][1]=1;
resultados [4][2]="Irlanda";
resultados [4][3]=0;
resultados [5][0]="Irlanda";
resultados [5][1]=1;
resultados [5][2]="Polonia";
resultados [5][3]=1;
resultados [6][0]="Irlanda";
resultados [6][1]=1;
resultados [6][2]="Escocia";
resultados [6][3]=1;
resultados [7][0]="Alemanha";
resultados [7][1]=3;
resultados [7][2]="Polonia";
resultados [7][3]=1;
resultados [8][0]="Escocia";
resultados [8][1]=2;
resultados [8][2]="Alemanha";
resultados [8][3]=3;
resultados [9][0]="Irlanda";
resultados [9][1]=1;
resultados [9][2]="Alemanha";
resultados [9][3]=0;
resultados [10][0]="Escocia";
resultados [10][1]=2;
resultados [10][2]="Polonia";
resultados [10][3]=2;
resultados [11][0]="Polonia";
resultados [11][1]=2;
resultados [11][2]="Irlanda";
resultados [11][3]=1;
for (int i=0; i<resultados.length; i++){
for (int j=0; j<resultados[i].length; j++){
System.out.print(resultados[i][j] + " - ");
}
System.out.println();
}
}
}
This modeling is forced by exercise ? It is that it is not good at all.
– Isac
he asks to define a two-dimensional matrix of String that represents the results of combinations in a tournament, listing the scores of each team in a list.
– igor camargo
If it’s a two-dimensional matrix of
String
is not what you have in the code at this time. It has how to put the statement in the question too ? Or at least the part that matters it?– Isac
Define a two-dimensional array of Strings Representing the Results of Matches. and a four-element array of ints Representing Scores of Teams of Germany, Ireland, Poland and Scotland (in this order). The program Calculates total score for each team (3 points for a win, 1 for a draw, 0 for a defeat), puts them into the array and then prints it.
– igor camargo