Ejemplo de una aplicación que pide 10 números, que te muestre el mayor, menor y el intermedio.
package arreglomim;
import java.util.Scanner;
/**
*
* @author Carlos
*/
public class ArregloMIM {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
int [] array= new int[11];
int aux;
int i,j;
Scanner in= new Scanner(System.in);
for(i=1;i<array.length;i++)
{
System.out.print("Ingrese el numero "+i+": ");
array[i]=(int) Double.parseDouble(in.nextLine());
}
for(i=1;i<array.length;i++)
for(j=1;j<array.length-i;j++)
if(array[j]>array[j+1])
{
aux=(int) array[j]; array[j]=array[j+1]; array[j+1]=aux;
}
System.out.println("El número menor es: "+array[1]);
System.out.println("El número intermedio es: "+array[5]);
System.out.println("El número mayor es: "+array[10]);
}
}
El resultado es:
run:
Ingrese el numero 1: 5
Ingrese el numero 2: 10
Ingrese el numero 3: 15
Ingrese el numero 4: .30
Ingrese el numero 5: 45
Ingrese el numero 6: 100
Ingrese el numero 7: 45
Ingrese el numero 8: -9
Ingrese el numero 9: -5
Ingrese el numero 10: 2
El número menor es: -9
El número intermedio es: 5
El número mayor es: 100
GENERACIÓN CORRECTA (total time: 19 seconds)