Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

image text in transcribed

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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

DNA Databases

Authors: Stefan Kiesbye

1st Edition

0737758910, 978-0737758917

More Books

Students also viewed these Databases questions

Question

5. List the forces that shape a groups decisions

Answered: 1 week ago

Question

4. Identify how culture affects appropriate leadership behavior

Answered: 1 week ago