Write a console program with the following methods:
createRandomArray: Creates an array of random numbers. Parameters are the length of the array, the minimum value, and the maximum value of each random number.getDigitSum: Calculates the digit sum of a number.toString: Creates a string representation of an array. Each integer in the array is separated by a comma.Your program, without methods, can look like this:
int[] randNrs = createRandomArray(10, 0, 200);
int[] digitSums = new int[randNrs.Length];
for (int i = 0; i < digitSums.length; i++)
{
int digitSum = getDigitSum(randNrs[i]);
digitSums[i] = digitSum;
}
System.out.println("Random numbers: ");
System.out.println(toString(randNrs));
System.out.println("Digit sums: ");
System.out.println(toString(digitSums));
Example program output:
Random numbers: 158, 124, 179, 44, 86, 189, 121, 168, 194, 106 Digit sums: 14, 7, 17, 8, 14, 18, 4, 15, 14, 7