Question & Answer: The program needed should be using JAVA and it shold compile a list of instruments from different instrument families. A family o…..

The program needed should be using JAVA and it shold compile a list of instruments from different instrument families. A family of musical Instruments is a grouping of several different but related sizes or types of instruments. Please comment some families are:

Brass Family – A brass instrument is a musical instrument that produces sound by sympathetic vibration of air in a tubular resonator in sympathy with the vibration of the player’s lips.
Ref:https://en.wikipedia.org/wiki/Brass_instrument (Links to an external site.)Links to an external site.

Strings Family – String instruments, stringed instruments, or chordophones are musical instruments that produce sound from vibrating strings.
Ref:https://en.wikipedia.org/wiki/String_instrument (Links to an external site.)Links to an external site.

Woodwind Family – Woodwind instruments are a family of musical instruments within the more general category of wind instruments. There are two main types of woodwind instruments: flutes and reed instruments (otherwise called reed pipes). What differentiates these instruments from other wind instruments is the way in which they produce their sound.
Ref:https://en.wikipedia.org/wiki/Woodwind_instrument (Links to an external site.)Links to an external site.

Percussion Family – A percussion instrument is a musical instrument that is sounded by being struck or scraped by a beater (including attached or enclosed beaters or rattles); struck, scraped or rubbed by hand; or struck against another similar instrument.
Ref:https://en.wikipedia.org/wiki/Percussion_instrument (Links to an external site.)Links to an external site.

Constraints

Limit the number of families to the list above

Use one separate (external to the main class) abstract superclass: Instrument

Use three separate (external to the main class) abstract subclasses that extend Instrument:

BlownInstrument
Fingered
Struck

Use four separate (external to the main class) subclasses (families) that extend the appropriate three above:

Brass
Strings
Woodwind
Percussion

Requirements

Display the menu shown in the downloadable PDF example

Request the number of instruments to be entered

All instruments should be placed into an array (you can use one array per family or one array for all entered) so they may be displayed

Use set and get methods where appropriate

Implement a loop that will allow the user to enter more instruments

Use exception handling and validation where appropriate

Expected Output—User input is in ​​BOLD

Select one of the following instrument families:

1. Brass

2. String

3. Woodwind

4. Percussion

5. Display all instruments

6. Exit

->: 1

How many brass instruments would you like to enter? ->: 3

Enter instrument #2->: bugle

Enter instrument #2->: trumpet

Enter instrument #3->: tuba

Display instruments? (Y for Yes, N for No)->: n

Enter more instruments? (Y for Yes, N for No)->: y

1. Brass

2. String

3. Woodwind

4. Percussion

5. Display all instruments

6. Exit

->: 2

How many string instruments would you like to enter? ->: 2

Enter instrument #1->: guitar

Enter instrument #2->: harp

Display instruments? (Y for Yes, N for No)->: n

Enter more instruments? (Y for Yes, N for No)->: y

1. Brass

2. String

3. Woodwind

4. Percussion

5. Display all instruments

6. Exit

->: 3

How many wood wind instruments would you like to enter? ->: 2

Enter instrument #1->: clarinet

Enter instrument #2->: oboe

Display instruments? (Y for Yes, N for No)->: n

Enter more instruments?

Expert Answer

 

File Name: Instrument.java

public abstract class Instrument {

}

File Name: BlownInstrument.java

public abstract class BlownInstrument extends Instrument {

}

File Name: Fingered.java

public abstract class Fingered extends Instrument {

}

File Name: Struck.java

public abstract class Struck extends Instrument {

}

File Name: Brass.java

public class Brass extends BlownInstrument {

}

File Name: Strings.java

public class Strings extends Fingered {

}

File Name: Woodwind.java

public class Woodwind extends BlownInstrument {

}

File Name: Percussion.java

public class Percussion extends Fingered {

}

File Name: DemoInstruments.java

public class DemoInstruments {

int numberBrass, numberStrings, numberWoodWind, numberPercussion;

public void static void main(String args[]) {

int choice = 0;

String[] brassFamily;

String[] stringsFamily;

String[] woodwindFamily;

String[] percussionFamily;

int number;

String family;

DemoInstruments demoInstruments = new DemoInstruments();

Scanner scan = new Scanner(new DataInputStream(System.in));

System.out.println(“Select one of the following instrument families”);

do {

System.out.print(“1. Brassn2. Stringn3 Woodwindn4. Percussionn5. Display all instrumentsn6. Exitn->: “);

choice = scan.nextInt();

switch(choice) {

case 1:

System.out.println(“How many Brass instruments would you like to enter? ->”);

numberBrass = scan.nextInt();

brassFamily = demoInstruments.addInstruments(brassFamily, scan, numberBrass);

break;

case 2:

System.out.println(“How many String instruments would you like to enter? ->”);

numberStrings = scan.nextInt();

stringsFamily = demoInstruments.addInstruments(stringsFamily, scan, numberStrings);

break;

case 3:

System.out.println(“How many Woodwind instruments would you like to enter? ->”);

numberWoodWind = scan.nextInt();

woodwindFamily = demoInstruments.addInstruments(woodwindFamily, scan, numberWoodWind);

break;

case 4:

System.out.println(“How many Percussion instruments would you like to enter? ->”);

numberPercussion = scan.nextInt();

percussionFamily = demoInstruments.addInstruments(percussionFamily, scan, numberPercussion);

break;

case 5:

if(numberBrass != 0) {

System.out.println(“Brass Family”);

for(int i=0; i<numberBrass; i++)

System.out.println(brassFamily[i]);

}

if(numberStrings != 0) {

System.out.println(“Strings Family”);

for(int i=0; i<numberStrings; i++)

System.out.println(stringsFamily[i]);

}

if(numberWoodWind != 0) {

System.out.println(“Woodwind Family”);

for(int i=0; i<numberWoodWind; i++)

System.out.println(woodwindFamily[i]);

}

if(numberPercussion != 0) {

System.out.println(“Percussion Family”);

for(int i=0; i<numberPercussion; i++)

System.out.println(percussionFamily[i]);

}

break;

case 6:

break;

}

}while(choice != 6);

}

public String[] addInstruments(String[] instruments, Scanner scan, number) {

intruments[] = new String[number];

for(int i=1; i<=number; i++) {

System.out.print(“Enter instrument #” + i + “->:”);

instruments[i-1] = scan.next();

}

return instruments;

}

}

Still stressed from student homework?
Get quality assistance from academic writers!