Occupy helps, I have to make a program that fills two arrays with random numbers, then compare sume two numbers of an arrangement and compare them with the sum of the second, and indicate which is the largest number.
The problem is that I do not understand well how to do the first part, I tried to generate a random number code but I do not know how to save it in the array.
Code for random:
for (int i = 0; i < 14; i++) {
Random generadorAleatorios = new Random();
int numeroAleatorio = 1 + generadorAleatorios.nextInt(14);
System.out.println(numeroAleatorio);
}
Then to compare them I have this code:
Double compNumeros[];// arreglo para comparar numeros
compNumeros = new Double[10];
System.out.println("");// para dejar un espacio en pantalla
try {
System.out.println("Debe de ingresar 10 digitos decimales");
for (int i = 0; i < compNumeros.length; i++) {
System.out.println("Digite el valor a ingresar:");
compNumeros[i] = teclado.nextDouble();
teclado.nextLine();
}
} catch (Exception e) {
System.out.println("Ingreso un dato erroneo");
System.out.println("Vuelva a Iniciar el programa");
}
Double max, min;
min = max = compNumeros[0];
for (int i = 0; i < compNumeros.length; i++) {
if (min > compNumeros[i]) {
min = compNumeros[i];
}
if (max < compNumeros[i]) {
max = compNumeros[i];
}
System.out.println("Segun el analisis realizado, los datos son los siguientes:");
System.out.println("El Numero Mayor ingresado es: " + max);
System.out.println("El Numero Minimo Ingresado es: " + min);
System.out.println("Fin del Programa");
But I have problems with the part of how to save in the arrangements.
I thank you for guiding me