Question: Write a program that creates an array with a size defined by the user and fill that array with random numbers that are between 0

Write a program that creates an array with a size defined by the user and fill that array with random numbers that are between 0 and the size of the array and display the amount of even and odd numbers in that array.

Rules:

The size of the array has to be dynamic, that is, defined by the user.

The random numbers in the array have to be between 0 and the size of the array (last one included). For example, if the user enters 10 for the size, the numbers should be between 0-10, both included:

[3, 1, 8, 0, 1, 4, 10, 8, 6, 8]

After getting the array size from the user and generating the array with random numbers, please display to the user the array that has been generated like in an example above. To display that, use Arrays.toString() method. For example, if your int array is named myArray, to display the contents of it without looping, use :

System.out.println(Arrays.toString(myArray));

Arrays is a class in java.util package that has many useful methods. Make sure to import java.util.Arrays so that your code compiles.

The next step is to display the amount of even and odd numbers in your randomly generated array. 0 also counts as an even number.

in java please follow the instructions

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!