subject

Declare an array to hold eight integers. Use a for loop to add eight random integers, all in the range from 50 to 100, inclusive, to this array. Duplicates are okay. Next, pass the array to a method that sorts the array and returns another array containing only the largest and smallest elements in the original array. Print these two values in main. Then use a foreach loop to display all elements of the sorted array on one line separated by a single space. This latter loop should also count the odd and even numbers in the array and determine the sum of all elements in the array. SAMPLE OUTPUT The lowest element is 59 The highest element is 96 Here is the array 59 64 76 77 80 88 91 96 Evens: 5, odds: 3 Total: 631

my code:

I am stuck on the problem to return the highest value and lowest value. Also on sorting the randomly generated integers. All in Java programming.

private static Random rand = new Random();

public static void main(String[] args){
int[] randomEight = numbers();
// printArray(randomEight);
System. out. println("The lowest element is");
System. out. println("The highest element is");
System. out. println("Here is the array");
// System. out. println(Arrays. toString(randomEight));
System. out. println();
for(int i = 0; i System. out. println(randomEight[i] + " ");
}
}
}

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 05:20
Write a program called assignment3 (saved in a file assignment3.java) that computes the greatest common divisor of two given integers. one of the oldest numerical algorithms was described by the greek mathematician, euclid, in 300 b.c. it is a simple but very e↵ective algorithm that computes the greatest common divisor of two given integers. for instance, given integers 24 and 18, the greatest common divisor is 6, because 6 is the largest integer that divides evenly into both 24 and 18. we will denote the greatest common divisor of x and y as gcd(x, y). the algorithm is based on the clever idea that the gcd(x, y) = gcd(x ! y, y) if x > = y and gcd(x, y) = gcd(x, y ! x) if x < y. the algorithm consists of a series of steps (loop iterations) where the “larger” integer is replaced by the di↵erence of the larger and smaller integer. this continues until the two values are equal. that is then the gcd.
Answers: 3
question
Computers and Technology, 23.06.2019 00:30
Which one of the following is considered a peripheral? a software b mouse c usb connector d motherboard
Answers: 2
question
Computers and Technology, 23.06.2019 12:50
Which syntax error in programming is unlikely to be highlighted by a compiler or an interpreter? a variable name misspelling a missing space a comma in place of a period a missing closing quotation mark
Answers: 1
question
Computers and Technology, 24.06.2019 12:50
When is it most apprpriate for a development team to change the definition of done
Answers: 1
You know the right answer?
Declare an array to hold eight integers. Use a for loop to add eight random integers, all in the ran...
Questions
question
Social Studies, 27.06.2019 17:30
question
Mathematics, 27.06.2019 17:30