Question: 1. Swap.java in Java Read an integer from keyboard, for example 25, or 2500. Use this number to determine the size of array myArray, read

1. Swap.java in Java Read an integer from keyboard, for example 25, or 2500. Use this number to determine the size of array myArray, read each distinctive element value one by one from the keyboard, and store/set them in this array. Find the position (or index) of the maximum and minimum values in the array, and swap these two (i.e., move the biggest element to the position of the smallest, and move the smallest element to the position of the biggest, while retain the rest without any change).

At the end, apply System.out.println(Arrays.toString(myArray)) to print out each element of myArray. If necessary, include import java.util.*; or import java.util.Arrays; The result must show the same sequence as you enter these values via keyboard, except for these two swapped elements. Without using advanced language such as sort and method calls

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!