[Duvida] Top3 BUILD FAILED

0 respostas
java
V

Olá amigos, estou com um problema nesse código ele apresenta o seguinte erro
Error: Could not find or load main class JavaApplication95
Caused by: java.lang.ClassNotFoundException: JavaApplication95
C:\Users\arthu\AppData\Local\NetBeans\Cache\11.1\executor-snippets\run.xml:111: The following error occurred while executing this line:
C:\Users\arthu\AppData\Local\NetBeans\Cache\11.1\executor-snippets\run.xml:68: Java returned: 1
BUILD FAILED (total time: 0 seconds)

aqui está o código:

package arrays_j;

import java.util.Arrays;

import java.util.Scanner;

public class JavaApplication95 {

public static int TAM = 20;
static Scanner sc = new Scanner(System.in);

public static void main(String[] args) {
    String[] nomes = new String[TAM];
    int[] vencimentos = new int[TAM];
    int tamArray = lerVencimentos(nomes, vencimentos);
    int[] top = calcularTop(nomes, vencimentos, tamArray);
    String[] nomesTop = escreverTop(top, nomes, vencimentos);
    imprimirTop(top, nomesTop, vencimentos);
}

public static int lerVencimentos(String[] nomes, int[] venc) {
    int i = 0;
    String aux = sc.nextLine();
    while (!aux.equals("FIM") && i < nomes.length) {
        nomes[i] = aux;
        venc[i] = sc.nextInt();
        i++;
        if (i < nomes.length) {
            sc.nextLine();
            aux = sc.nextLine();
        }
    }
    return i;
}

public static int[] calcularTop(String[] nomes, int[] venc, int tam) {
    int[] top = new int[3];
    int aux = venc[0];
    venc[0] = -1;
    for (int i = 0; i < tam; i++) {
        if (venc[i] > venc[top[2]]) {
            if (venc[i] > venc[top[1]]) {
                if (venc[i] > venc[top[0]]) {
                    venc[0] = aux;
                    top[2] = top[1];
                    top[1] = top[0];
                    top[0] = i;
                } else {
                    top[2] = top[1];
                    top[1] = i;
                }
            } else {
                top[2] = i;
            }
        }
    }
    venc[0] = aux;
    return top;
}

public static String[] escreverTop(int[] top, String[] nomes, int[] venc) {
    String[] nomesTop = new String[3];
    String aux;
    for (int i = 0; i < 3; i++) {
        nomesTop[i] = nomes[top[i]];
    }
    if (venc[top[0]] == venc[top[1]] && venc[top[1]] == venc[top[2]]) {
        Arrays.sort(nomesTop);
    } else {
        if (venc[top[0]] == venc[top[1]]) {
            if (nomesTop[0].compareTo(nomesTop[1]) > 0) {
                aux = nomesTop[1];
                nomesTop[1] = nomesTop[0];
                nomesTop[0] = aux;
            }
        }
        if (venc[top[1]] == venc[top[2]]) {
            if (nomesTop[1].compareTo(nomesTop[2]) > 0) {
                aux = nomesTop[2];
                nomesTop[2] = nomesTop[1];
                nomesTop[1] = aux;
            }
        }
    }
    return nomesTop;
}
//    public static String[] escreverTop(int[] top, String[] nomes, int[] venc) {

//        String[] nomesTop = new String[3];

//        String aux;

//        for (int i = 0; i < 3; i++) {

//            nomesTop[i] = nomes[top[i]];

//        }

//        if (venc[top[0]] == venc[top[1]] && venc[top[1]] == venc[top[2]]) {

//            if (nomesTop[0].compareTo(nomesTop[1]) > 0) {

//                aux = nomesTop[1];

//                nomesTop[1] = nomesTop[0];

//                nomesTop[0] = aux;

//                if (nomesTop[1].compareTo(nomesTop[2]) > 0) {

//                    aux = nomesTop[2];

//                    nomesTop[2] = nomesTop[1];

//                    nomesTop[1] = aux;

//                }

//            } else {

//                if (nomesTop[1].compareTo(nomesTop[2]) > 0) {

//                    aux = nomesTop[2];

//                    nomesTop[2] = nomesTop[1];

//                    nomesTop[1] = aux;

//                }

//            }

//        } else {

//            if (venc[top[0]] == venc[top[1]]) {

//                if (nomesTop[0].compareTo(nomesTop[1]) > 0) {

//                    aux = nomesTop[1];

//                    nomesTop[1] = nomesTop[0];

//                    nomesTop[0] = aux;

//                }

//            }

//            if (venc[top[1]] == venc[top[2]]) {

//                if (nomesTop[1].compareTo(nomesTop[2]) > 0) {

//                    aux = nomesTop[2];

//                    nomesTop[2] = nomesTop[1];

//                    nomesTop[1] = aux;

//                }

//            }

//        }

//        return nomesTop;

//    }
public static void imprimirTop(int[] top, String[] nomesTop, int[] venc) {
    for (int i = 0; i < 3; i++) {
        System.out.printf("#%d:%s:%d\n", i + 1, nomesTop[i], venc[top[i]]);
    }
}

}

Criado 16 de novembro de 2019
Respostas 0
Participantes 1