Question: Part 2. A 1D-array with distinct elements can be used to represent a set. Write an interactive Java program that prompts for and reads the

 Part 2. A 1D-array with distinct elements can be used to

represent a set. Write an interactive Java program that prompts for and

Part 2.

A 1D-array with distinct elements can be used to represent a set. Write an interactive Java program that

prompts for and reads the sizes of two 1D-arrays and then it prompts for and reads distinct values in each of the

two arrays. It then does the following:

. It calls a static method theUnion passing to it the two arrays. The method returns a reference to a 1D-

array that contains the set union of the two arrays.

. It displays the elements in the set union.

Note:

. Your program must use appropriate loops.

. Assume that the sizes read are each greater or equal to zero.

. Enter distinct elements in the two arrays and do not test whether the elements are distinct or not.

(i.e., assume that the user will enter distinct elements).

. The array reading must be done in the main method and not in the theUnion static method.

. The method theUnion must not contain calls to I/O methods.

. The created set union must have distinct elements (i.e., each element must not be repeated.)

Sample program runs:

reads the sizes of two 1D-arrays and then it prompts for and

Question 3: Let us define a special integer x as an integer sati sfying the following two conditi ons Condition01: The integer x is an odd integer equal to or greater than 3 that has one divisor in the interval 1, vx] Condition02: The integer x reads the same forward and backwards. Ex amples: 5, 22, 313, 44044 Your program must have 4 static methods: main getSpecia!Integers otherwise it retuns false. .boole an method satisfiesCon dition02 that returms true if the passed integer sati sfies condition02 that retums true if the passed integer satisfies otherwi se it returns false The main method prompts for and reads a positive integer limit. The main method must recover from invali d input and from inputMi smatchException. I the input is vali d, the main method passes the limit to the method getSpecialIntegers. The method getSpecialIntegers returns a reference to a 1D-array that contains all the satisfiesC on dition02

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!