Question: JAVA Prompt: Produce a JAVA program that takes numbers as user input and then copies those numbers into a single array. The user input will

JAVA

Prompt:

Produce a JAVA program that takes numbers as user input and then copies those numbers into a single array. The user input will end if -1 is entered. (IMPORTANT: -1 will not go into the array!!!).

1) Initially declare the array such that it can hold only two elements. Then, double the size of the array if the array requires more space.

2) Make sure the array does not accept duplicate inputs! (a check function)

3) Copy the contents of the array to another int array using System.arraycopy

4) Copy the contents of the array into an array of Integer (wrapper class)

5) Display:

a) Display contents of the array from the last number entered to the first number entered.

b) Display the contents of the array in ascending order. Use Arrays.sort()

c) Display the contents of the array in descending order. Use Arrays.sort(Collections.reverseOrder()) OR MAY have to use Arrays.sort(Collections.reverseOrder(Comparator))

(Note: The Arrays class has a sort method. Keep in mind that it is the Arrays and not the Array class).

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!