I thought it was all right with the code... but i'm not getting to the answer I want...
That's the input file i have to use to solve it
exemplo1.txt
That's the answer
salva.jpg
That's what I am getting.... (the number's at the right are the results)
salva2.jpg
Here's the code, appreciate who could help me...
Solved! apparently JAVA doesn't work well with 3 "for" inside each other
Import java.util.Scanner; import java.util.Locale; public class ep1 { public static void main (String [] args) { Scanner ler = new Scanner (System.in); ler.useLocale(Locale.ENGLISH); int nCargos = ler.nextInt(); String [] cargo = new String [nCargos]; double [][] peso = new double [nCargos] [14]; for (int i = 0; i < nCargos; i++) { cargo[i] = ler.nextLine(); //I can't read the string if i do not use it twice, idk why also cargo[i] = ler.nextLine(); System.out.print (cargo[i] + " : \n"); System.out.println(); for (int u = 0; u < 14; u++) { peso [i] [u] = ler.nextDouble(); System.out.printf (peso[i][u] + " "); } System.out.println(); System.out.println("-------------------------------------------------------------"); } int nPessoas = ler.nextInt(); String [] nome = new String [nPessoas]; double [][] pontos = new double [nPessoas] [14]; double media = 0; double [] medias = new double [nPessoas]; for (int D = 0; D < nPessoas; D++) { nome [D] = ler.nextLine(); // Mesmo caso do Scanner nextLine anterior nome [D] = ler.nextLine(); System.out.print (nome[D] + " : \n"); System.out.println(); for (int c = 0; c < 14; c++) { pontos [D] [c] = ler.nextDouble(); System.out.print (pontos[D][c] + " "); media += pontos [D] [c]; } media = media/14; System.out.println(); System.out.println ("A media de "+ nome[D] + " e: "+ media); System.out.println(); System.out.println("-------------------------------------------------------------"); } double s = 0; double s1 = 0; double den = 0; double [][] pts = new double [nCargos] [nPessoas]; for (int i = 0; i < nCargos; i++) { for (int k = 0; k < nPessoas; k++) { for (int c = 0; c < 14; c++) { s1 = pontos[k][c] * peso[i][c]; // Something is wrong around here den += peso[i][c]; s += s1; } System.out.println (s + " " + den); pts [i][k] = s/den; System.out.print (nome [k] + "tem a média " + pts [i] [k] + " para o cargo " + cargo [i] + " \n"); System.out.println (); } } System.out.println (); System.out.println("-------------------------------------------------------------"); String [] nomes2 = nome; double te = 0; String tem = ""; for (int i = 0; i < nCargos; i++) { System.out.println (cargo[i]); System.out.println(); for (int g = 30; g > 0; g--) { for (int k = nPessoas - 1; k > 0; k--) { if ( pts [i] [k] > pts [i] [k-1]) { te = pts [i] [k]; pts [i] [k] = pts [i] [k-1]; pts [i] [k-1] = te; tem = nomes2[k]; nomes2 [k] = nomes2 [k-1]; nomes2 [k-1] = tem; } } } for (int c = 0; c < nomes2.length; c++) { System.out.println (nomes2 [c] + " " + pts [i] [c]); } System.out.println(); } } }