Question: Write a Java code that read 8 positive integers from the user and store them in an array. The program should ensure that the
Write a Java code that read 8 positive integers from the user and store them in an array. The program should ensure that the numbers of the array are positive. If not, the program will keep asking user to enter positive values. Then, it finds the position (or index) of the maximum and minimum values in the array, and swap them (move the max element to the position of the min, and move the min element to the position of the max). Then it calculates the median of the elements of this array (for this step an ascending order sort should be done before calculating the median). Then run the code again for integer array of size 7. Loop and conditionals should be used otherwise marks will be deducted. Don't hardcode the output otherwise marks will be deducted.
Step by Step Solution
3.40 Rating (150 Votes )
There are 3 Steps involved in it
import javautilArrays import javautilScanner public class MaxMinMedian public static void ... View full answer
Get step-by-step solutions from verified subject matter experts
