Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The following program is supposed to generate 100 random numbers and display how

ID: 3849663 • Letter: T

Question

The following program is supposed to generate 100 random numbers and display how many are odd and how many are even. But it has some errors. Fix those errors so that the program generates the expected output correctly def main(): currentNumber = 0 totalNumbers = 100 for counter in range (totalNunbers): currentNumber = random.randint(1, 1000) if isEven(currentNumber): evenCounter+ = 1 else: oddCounter+ = 1 print ('Out of', totalNumbers, 'random numbers, ', oddCounter, 'were odd, and', evenCounter, 'were even.') # The isEven function returns True if number is even False if odd. def is Even(number): if num % 2 == 0: return True else: return False main()

Explanation / Answer

public static void main(String[] args) {

  
int[] randomNumbers = new int[25];
int[] evenNumbers = new int[25];
int[] oddNumbers = new int[25];
int k = 0, l = 0;
for (int index = 0; index < randomNumbers.length; index++) {
randomNumbers[index] = (int) (Math.random() * 99);
}
for (int i = 0; i < 25; i++) {
if (randomNumbers[i] % 2 == 0) {
evenNumbers[k] = randomNumbers[i];
k++;
} else {
oddNumbers[l] = randomNumbers[i];
l++;
}
}
}

this is the logic,use it in your code.