Respuesta :
Answer:
Explanation:
The following code is written in Java. It randomly generates 10 integers and adds them to an integer array called myArr. Then it loops through the array calculating if each number is even or odd. If it is even it adds 1 to the evenCount variable and prints out the number saying that it is even. Otherwise it adds 1 to the oddCount variable and prints the number saying that it is odd. The program was tested and the output can be seen in the attached image below.
import java.util.*;
class Brainly {
// Main Method
public static void main(String[] args) {
Random rand = new Random();
int[] myArr = new int[10];
for (int i = 0; i<10; i++) {
int n = rand.nextInt(101);
myArr[i] = n;
}
int evenCount = 0;
int oddCount = 0;
for (int x : myArr) {
if ((x % 2) == 0) {
evenCount += 1;
System.out.println(x + " is Even");
} else {
oddCount +=1;
System.out.println(x + " is Odd");
}
}
System.out.println("The Array has a total: ");
System.out.println(evenCount + " Even Numbers");
System.out.println(oddCount + " Odd Numbers");
}
}
