Exercise: Array Statistics
Write a console program that:
- creates an
int
array of length 10
- fills that array with random numbers from 0 to 15 inclusive
- prints the array exactly as shown below (no trailing comma)
- prints the smallest value in the array
- prints how many times the smallest value occurs in the array
- prints how many even numbers there are in the array (even means divisible by two without a remainder)
- prints the array in reverse.
Your program output should look exactly like this:
Random array: 14, 14, 14, 6, 5, 9, 8, 7, 6, 6
Smallest number is 5 and occurs 1 time
Amount of even numbers: 7
Array in reverse: 6, 6, 7, 8, 9, 5, 6, 14, 14, 14
Another example run:
Random array: 12, 0, 0, 2, 15, 5, 14, 15, 7, 9
Smallest number is 0 and occurs 2 times
Amount of even numbers: 5
Array in reverse: 9, 7, 15, 14, 5, 15, 2, 0, 0, 12
Hand in instructions
- Make sure your program runs correctly.
- Follow Java naming conventions of variables.
- Make sure your program is well-formatted.
- Hand in your program by uploading Main.java to Moodle.