so here is the code i have after doing some work. How do i put the three arrays into a textview that will display on my phone. I basically have to create random numbers in an array, add them up and thats the 3rd array
private int[] arrayOne = new int[5], arrayTwo = new int[5], arrayThree = new int[5];
public int randomNumbers(){
Random rand = new Random();
return rand.nextInt(20) -10;
}
public void generateArrays(){
for(int i = 0; i < arrayOne.length; i++) {
arrayOne[i] = randomNumbers();
arrayTwo[i] = randomNumbers();
}
}
public void arraySum(){
for(int i = 0; i < arrayOne.length; i++){
int temp = arrayOne[i] + arrayTwo[i];
if (temp < 0) temp = 0;
arrayThree[i] = temp;
}
}
}
Aucun commentaire:
Enregistrer un commentaire