Question: 3 . 1 8 LAB: Set basIcS Java Given the user inputs, complete a program that does the following tasks: Define a set, fruits, containing

3.18 LAB: Set basIcS
Java
Given the user inputs, complete a program that does the following tasks:
Define a set, fruits, containing the user inputs: my_fruit1, my_fruit2, and my_fruit3.
Add the user inputs, your_fruit1 and your_fruit2, to fruits.
Add the user input, their_fruit, to fruits.
Add your_fruit1 to fruits.
Remove my_fruit1 from fruits.
Observe the output of each print statement carefully to understand what was done by each task of the program.
Note: For testing purposes, sets are printed using sorted() for comparison, as in the book's examples.
Ex: If the input is:
apple
peach
lemon
apple
pear
plum
the output is:
[ 'apple', 'lemon', 'peach']
['apple', 'lemon', 'peach', 'pear']
['apple', 'lemon', 'peach', 'pear', 'plum']
['apple', 'lemon', 'peach', 'pear', 'plum']
['lemon', 'peach', 'pear', 'plum']10.8 LAB: Instrument information (derived classes)
Given the base class Instrument, define a derived class StringInstrument for string instruments with a constructor that
initializes the attributes of the Instrument class as well as new attributes of the following types
integer to store the number of strings
integer to store the number of frets
boolean to store whether the instrument is bowed
Ex. If the input is:
Drums
Zildjian
2015
2500
Guitar
Gibson
2002
1200
6
19
False
the output is:
Instrument Information:
Name: Drums
Manufacturer: Zildjian
Year built: 2015
Cost: 2500
Instrument Information:
Name: Guitar
Manufacturer: Gibson
Year built: 2002
Cost: 1200
Number of strings: 6
Number of frets: 19
 3.18 LAB: Set basIcS Java Given the user inputs, complete a

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!