Question: Java Lab-IreeSets Part #1 : TreeSet Write a program that creates a TreeSet consisting of ten random characters ranging from 'a' through z. Create two

Java

Java Lab-IreeSets Part #1 : TreeSet Write a program that creates a

Lab-IreeSets Part #1 : TreeSet Write a program that creates a TreeSet consisting of ten random characters ranging from 'a' through z. Create two tree sets, say TS1 and TS2. Print them out to verify they are in order. Then write a method to find the union of the two tree sets. It should have this signature: Public static void union(TreeSet, TreeSet Do the same for the intersection: Public static void intersection(TreeSet, TreeSet) Print out the results of the union and intersection) methods Part #2: TreeSetobject> Design a simple Car class consisting of four data elements: price, year, make and model. Create three Car objects in the main0) method. Then create a TreeSetCa> consisting of those three Car objects. The IreeSet will reject the Car objects if the class dosen't have a compareo method. Write a compareo) method using price as the basis of comparison. Then add the Car objects to the TneeSet Print out the JreSet and verifly the order is correct (Le. based on price) Challenge: Can you write a version of campareLo0 that will sort the objects based on model name

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Part 1 TreeSet Step 1 Import Necessary Libraries Ensure you import the necessary classes for TreeSet and Random java import javautilTreeSet import jav... View full answer

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!