package javaguru;
import java.util.Scanner;
import java.util.Random;
public class hw {
public static void main(String[] args) {
int[] cats = new int[10];
int countEven = 0;
int countOdd = 0;
for (int i = 0; i < cats.length; i++) {
cats[i] = ((int) (Math.random()*100));
System.out.print(cats[i] + " ");
if ( cats[i] % 2 != 0 ){
countOdd++;
} else {
countEven++;
}
System.out.println();
System.out.println("Odd count " + countOdd);
System.out.println( "Even count " + countEven );
Объяснение:
package javaguru;
import java.util.Scanner;
import java.util.Random;
public class hw {
public static void main(String[] args) {
int[] cats = new int[10];
int countEven = 0;
int countOdd = 0;
for (int i = 0; i < cats.length; i++) {
cats[i] = ((int) (Math.random()*100));
System.out.print(cats[i] + " ");
if ( cats[i] % 2 != 0 ){
countOdd++;
} else {
countEven++;
}
}
System.out.println();
System.out.println("Odd count " + countOdd);
System.out.println( "Even count " + countEven );
}
}
Объяснение: