Write a console program that uses methods to:
int
array of length 4Your program output should look like this:
Array: 4, 8, 2, 1 Biggest number: 8 Product: 64 Amount of even numbers: 3 Reversed array: 1, 2, 8, 4Write these methods to accomplish the tasks:
createRandomNumbers
- creates an array of random integerstoString
- converts an integer array to a stringgetBiggestNumber
- gets the biggest integer from an integer arraygetProduct
- returns a BigDecimal
by multiplying the numbers in an integer arraycountEvenNumbers
- gets the amount of even numbers in an integer arrayreverseArray
- returns a new array with the numbers of the input array in reverse ordermain
method can look like this:
int randNrsLength = 4; int minIncl = 1; int maxIncl = 8; int[] randNrs = createRandomNumbers(randNrsLength, minIncl, maxIncl); int biggestNr = getBiggestNumber(randNrs); BigDecimal product = getProduct(randNrs); int evenNrCount = countEvenNumbers(randNrs); int[] reversed = reverseArray(randNrs); System.out.println("Array: " + toString(randNrs)); System.out.println("Biggest number: " + biggestNr); System.out.println("Product: " + product); System.out.println("Amount of even numbers: " + evenNrCount); System.out.println("Reversed array: " + toString(reversed));