por favor preciso de ajuda para fazer uma questão de prova, não sei nem por onde começar…se puderem me ajudar serei muito grato…
FASSA UM PROGRAMA QUE PREENCHA UM VETOR COM 10 NUMEROS INTEIROS ALEATOREO E UM SEGUNDO VETOR COM 5 NUMEROS INTEIROS ALEATORIO, CAUCULE E MOSTRE OS DOIS VETORES
RESULTANTES. SENDO QUE O PRIMEIRO VETOR RESULTANTE SERA COMPOSTO PELOS NUMEROS PARES GERADOS PELO ELEMENTO DO PRIMEIRO VETOR SOMADO A TODOS OS ELEMENTOS DO
SEGUNDO VETOR;
O SEGUNDO VETOR RESULTANTE SERA COMPOSTO PELA QUANTIDADE DE DIVISORES DOS NUMEROS IMPARES GERADO PELOS ELEMENTOS DO PRIMEIRO VETOR EM RELACAO AO SEGUNDO VETOR.
DESENVOLVA UMA SOLUÇÃO MODULARIZADA
fiz isso mas ta dando problema no vetor_result2…esse vetor tem que ser composto pela quantidade de divisores dos numeros impares gerado pelos elementos do primeiro vetor em relação ao segundo vetor…
import java.util.Random;
import javax.swing.JOptionPane;
public class exercitando {
private static final String Random = null;
/**
* @param args
*/
public static void main(String[] args) {
Random random = new Random();
int[] vetor = new int[10];
int somavetor =0;
int divisivel=0;
for(int i=0; i < vetor.length; i++) {
vetor [i] = 1+random.nextInt(10);
}
int [] vetor2 = new int [5];
for(int i=0; i < vetor2.length; i++) {
vetor2 [i] = 1+random.nextInt(10);
somavetor = somavetor + vetor[i] ;
}
int [] vetor_result = new int [5];
for(int i=0; i < vetor_result.length; i++) {
if (vetor [i] % 2==0){
vetor_result[i] = vetor [i] + somavetor;
System.out.println("resultante 1: " +vetor_result [i]);
}
}
int [] vetor_result2 = new int [5];
int cont=0;
int posicao =0;
for(int i = 0; i < vetor.length; i++){
if (vetor [i] % 2!=0 && vetor[i] % vetor2[i] == 0){
for(int b = 0; b < vetor2.length; b++){
cont++;
posicao = posicao + 1;
vetor_result2 [posicao] = cont;
}
}
System.out.println("resultante 2: " + vetor_result2 [posicao] );
}
}
}