I need to register 5 names and their heights, then show them all in ascending order. The problem is that I can only put the heights in the order, the names are in the order I typed. And also I am not able to use the double in place of the int for the height, because of the error. Here's my code: If I have something very wrong, it's because I'm still a beginner.
public static void main(String args[]) {
int numero = Integer.parseInt(JOptionPane.showInputDialog("Digite o número de pessoas a ser cadastrado "));
String vet[] = new String[numero];
int altura[] = new int[5];
int aux;
for (int i = 0; i < vet.length; i++) {
vet[i] = JOptionPane.showInputDialog("Digite o nome: ", null);
altura[i] = Integer.parseInt(JOptionPane.showInputDialog("Digite a altura: ", null));
}
for (int i = 0; i < altura.length; i++) {
for (int j = 0; j < (altura.length); j++) {
if (altura[i] < altura[j]) {
aux = altura[i];
altura[i] = altura[j];
altura[j] = aux;
}
}
}
for (int i = 0; i < altura.length; i++) {
System.out.println("Nome " + (i+1) + "º " + vet[i] + altura[i] + "");
}
}