Question

This is my main code (its about 90% done) :     public static void main(String[] args)...

This is my main code (its about 90% done) :

    public static void main(String[] args) {

        int instrumentFam = 0;
        Scanner input = new Scanner(System.in);

        System.out.println("Select one of the following instrument families: ");

        System.out.println("1.Brass\n 2.String\n 3.Woodwind\n 4.Percussion\n "
                + "5.Display all instruments\n 6.Exit");
        System.out.println("->: ");
        instrumentFam = input.nextInt();

        switch (instrumentFam) {
            case 1:

                int amount;
                String choice;

                System.out.println("How many brass instruments would you like to enter? ");
                amount = input.nextInt();

                String[] BrassNames = new String[amount];

                for (int i = 0; i < amount; i++) {
                    System.out.println("Enter instrument" + i);
                    BrassNames[i] = input.next();
                }

                System.out.println("Display instruments? (Y for Yes, N for No)");
                choice = input.next();

                if (choice.equalsIgnoreCase("Y")) {
                    for (int i = 0; i < amount; i++) {
                        System.out.println(BrassNames[i]);
                    }
                }
                        else
                        {
                            System.out.println("Enter more instruments? ");
                        }
               
               
               
                break;
                case 2: //String instruments
              

                System.out.println("How many string instruments would you like to enter? ");
                amount = input.nextInt();

                String[] StringNames = new String[amount];

                for (int i = 0; i < amount; i++) {
                    System.out.println("Enter instrument" + i);
                    StringNames[i] = input.next();
                }

                System.out.println("Display instruments? (Y for Yes, N for No)");
                choice = input.next();

                if (choice.equalsIgnoreCase("Y")) {
                    for (int i = 0; i < amount; i++) {
                        System.out.println(StringNames[i]);
                    }
                }
                        else
                        {
                            System.out.println("Enter more instruments? ");
                        }
               
               
                break;
                case 3: //Woodwind instruments
              

                System.out.println("How many woodwind instruments would you like to enter? ");
                amount = input.nextInt();

                String[] WoodwindNames = new String[amount];

                for (int i = 0; i < amount; i++) {
                    System.out.println("Enter instrument" + i);
                    WoodwindNames[i] = input.next();
                }

                System.out.println("Display instruments? (Y for Yes, N for No)");
                choice = input.next();

                if (choice.equalsIgnoreCase("Y")) {
                    for (int i = 0; i < amount; i++) {
                        System.out.println(WoodwindNames[i]);
                    }
                }
                        else
                        {
                            System.out.println("Enter more instruments? ");
                        }
               
                break;
                case 4: //Percusssion instruments
              

                System.out.println("How many percussion instruments would you like to enter? ");
                amount = input.nextInt();

                String[] PercussionNames = new String[amount];

                for (int i = 0; i < amount; i++) {
                    System.out.println("Enter instrument" + i);
                    PercussionNames[i] = input.next();
                }

                System.out.println("Display instruments? (Y for Yes, N for No)");
                choice = input.next();

                if (choice.equalsIgnoreCase("Y")) {
                    for (int i = 0; i < amount; i++) {
                        System.out.println(PercussionNames[i]);
                    }
                }
                        else
                        {
                            System.out.println("Enter more instruments? ");
                        }
             
                break;
                case 5://Display all instruments
                  
                    }
                }
        }

The part I need help with is that I need an abstract super class named "Instruments" that will hold a list of instruments of each family of instruments. For example, the brass family should have a list of these instruments: Trumpet, Fanfare trumpet, Trombone, Cornet, Saxhorn, Flugelhorn, Tenor horn, Baritone horn, Euphonium, Tuba, French horn, Sousaphone, Mellophone, Alphorn, Buccina, Bugle, Contrabass bugle, Carnyx, Cornett, Cornu, Dorb, German horn, Horn, Nabal, Nyele, Ophicleide, Post horn, Serpent, Shofar, Sringa, Tibetan horn, Vienna horn, Wagner tuba, Wazza?.

& so on for each family

0 0
Add a comment Improve this question Transcribed image text
Answer #1

import java.util.Scanner;

abstract class Instruments

{

public void brassInsrtumentsList()

{

System.out.println("\nBrass Family List of Instruments are:\n");

System.out.println("Trumpet, Fanfare trumpet, Trombone, Cornet, Saxhorn, Flugelhorn, Tenor horn, Baritone

horn,Euphonium, Tuba, French horn, Sousaphone, Mellophone, Alphorn, Buccina, Bugle, Contrabass bugle, Carnyx, Cornett,

Cornu, Dorb, German horn, Horn, Nabal, Nyele, Ophicleide, Post horn, Serpent, Shofar, Sringa, Tibetan horn, Vienna horn,

Wagner tuba, Wazza");

}

public void stringInsrtumentsList()

{

System.out.println("\nString Family List of Instruments are:\n");

System.out.println("Violin,Lyre,Cello,Viola,Double bass,Bass

guitar,Guitar,Mandolin,Banjo,Harp,Lute,Zither,Ukulele,Sanshin,Koto,Kit");

}

public void woodwindInsrtumentsList()

{

System.out.println("\nWoodwind Family List of Instruments are:\n");

System.out.println("Alto flute,Bass oboe,Bassoon,Bombard,Claghorn,Clarinet,Contrabass,Cor

anglais,Fipple,Flute,Melodica,Mouth organ,Oboe,Piccolo,Pipe,Pku,Pommer,Reclam de xeremies,Recorder,Reed

contrabass,Reeds,Sarrusophone,Saxophone,Shawm,Uilleann pipes");

}

public void percusssionInsrtumentsList()

{

System.out.println("\nPercusssion Family List of Instruments are:\n");

System.out.println("Bock-a-da-bock,Cabasa,Cajón,Castanets,Celesta,Chimes,Claves,Cowbell,Crash

cymbals,Crotales,Daxophone,Flexatone,Güiro,Handbells,Hi-hat,Lummi stick,Maraca,Marimba,Orchestra bells,Quadrangularis

,Reversum,Ratchet,Singing bowls,Slit drum,Steelpan,Suspended cymbal,Temple blocks,Thumb piano (or

Kalimba),Triangle,Txalaparta,Vibraphone,Vibraslap,Wood block,Xylophone");

}

}

class InstrumentsMain extends Instruments

{

public static void main(String[] args) {

int instrumentFam = 0;

Scanner input = new Scanner(System.in);

InstrumentsMain in=new InstrumentsMain();

do

{

System.out.println("Select one of the following instrument families: ");

System.out.println("1.Brass\n 2.String\n 3.Woodwind\n 4.Percussion\n "

+ "5.Display all instruments\n 6.Exit");

System.out.println("->: ");

instrumentFam = input.nextInt();

switch (instrumentFam) {

case 1:

int amount;

String choice;

System.out.println("How many brass instruments would you like to enter? ");

amount = input.nextInt();

String[] BrassNames = new String[amount];

in.brassInsrtumentsList();

for (int i = 0; i < amount; i++) {

System.out.println("Enter instrument" + (i+1));

BrassNames[i] = input.next();

}

System.out.println("Display instruments? (Y for Yes, N for No)");

choice = input.next();

if (choice.equalsIgnoreCase("Y")) {

for (int i = 0; i < amount; i++) {

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

}

}

else

{

System.out.println("Enter more instruments? ");

}

break;

case 2: //String instruments

  

System.out.println("How many string instruments would you like to enter? ");

amount = input.nextInt();

String[] StringNames = new String[amount];

in.stringInsrtumentsList();

for (int i = 0; i < amount; i++) {

System.out.println("Enter instrument" + (i+1));

StringNames[i] = input.next();

}

System.out.println("Display instruments? (Y for Yes, N for No)");

choice = input.next();

if (choice.equalsIgnoreCase("Y")) {

for (int i = 0; i < amount; i++) {

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

}

}

else

{

System.out.println("Enter more instruments? ");

}

break;

case 3: //Woodwind instruments

  

System.out.println("How many woodwind instruments would you like to enter? ");

amount = input.nextInt();

String[] WoodwindNames = new String[amount];

in.woodwindInsrtumentsList();

for (int i = 0; i < amount; i++) {

System.out.println("Enter instrument" + (i+1));

WoodwindNames[i] = input.next();

}

System.out.println("Display instruments? (Y for Yes, N for No)");

choice = input.next();

if (choice.equalsIgnoreCase("Y")) {

for (int i = 0; i < amount; i++) {

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

}

}

else

{

System.out.println("Enter more instruments? ");

}

break;

case 4: //Percusssion instruments

  

System.out.println("How many percussion instruments would you like to enter? ");

amount = input.nextInt();

String[] PercussionNames = new String[amount];

in.percusssionInsrtumentsList();

for (int i = 0; i < amount; i++) {

System.out.println("Enter instrument" + (i+1));

PercussionNames[i] = input.next();

}

System.out.println("Display instruments? (Y for Yes, N for No)");

choice = input.next();

if (choice.equalsIgnoreCase("Y")) {

for (int i = 0; i < amount; i++) {

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

}

}

else

{

System.out.println("Enter more instruments? ");

}

break;

case 5://Display all instruments

in.brassInsrtumentsList();

in.stringInsrtumentsList();

in.woodwindInsrtumentsList();

in.percusssionInsrtumentsList();

break;

  

case 6:System.exit(0);

depault: System.out.println("Invalid Choice! Enter your choice 1-5");

  

}

}while(instrumentFam!=6);

}

}

output:

C:WindowslSystem32\cmd.exe Microsoft Windows [Uersion 6.1.7601 1 Copyright <c> 2009 Microsoft Corporation. A1l rights reserueCCWindowstSystem32icmd.exe rass Family List of Instruments are: rumpet. Fanfare trumpet. Trombone. Cornet. Saxhorn Flugelhorn

Add a comment
Know the answer?
Add Answer to:
This is my main code (its about 90% done) :     public static void main(String[] args)...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • public static void main(String[] args) { int option=0;    while(option<8){ Scanner input=new Scanner(System.in); System.out.println("Welcome! Please enter...

    public static void main(String[] args) { int option=0;    while(option<8){ Scanner input=new Scanner(System.in); System.out.println("Welcome! Please enter your name"); String name=input.next(); Person user= new Person(name); System.out.println("Your id: "+user.getID()); System.out.println("Login successful"); System.out.println("------------------------------"); while(option!=7){ System.out.println("1.Create and host a new meeting"); System.out.println("2.Cancel a meeting"); System.out.println("3.Attend an existing meeting"); System.out.println("4.Leave a meeting"); System.out.println("5.Display my meetings"); System.out.println("6.Display meetings organized by me"); System.out.println("7.Logout"); System.out.println("8.Exit the app");    option=input.nextInt(); switch(option){ case 1: break; case 2: break; case 3: break; case 4: break; case 5: break; case 6: break;...

  • Project 7-3 Guessing Game import java.util.Scanner; public class GuessNumberApp {    public static void main(String[] args)...

    Project 7-3 Guessing Game import java.util.Scanner; public class GuessNumberApp {    public static void main(String[] args) { displayWelcomeMessage(); // create the Scanner object Scanner sc = new Scanner(System.in); String choice = "y"; while (choice.equalsIgnoreCase("y")) { // generate the random number and invite user to guess it int number = getRandomNumber(); displayPleaseGuessMessage(); // continue until the user guesses the number int guessNumber = 0; int counter = 1; while (guessNumber != number) { // get a valid int from user guessNumber...

  • import java.util.Scanner; public class creditScore { public static void main(String[]args) { // declare and initialize variables...

    import java.util.Scanner; public class creditScore { public static void main(String[]args) { // declare and initialize variables int creditScore; double loanAmount,interestRate,interestAmount; final double I_a = 5.56,I_b = 6.38,I_c = 7.12,I_d = 9.34,I_e = 12.45,I_f = 0; String instructions = "This program calculates annual interest\n"+"based on a credit score.\n\n"; String output; Scanner input = new Scanner(System.in);// for receiving input from keyboard // get input from user System.out.println(instructions ); System.out.println("Enter the loan amount: $"); loanAmount = input.nextDouble(); System.out.println("Enter the credit score: "); creditScore...

  • public static void main(String[] args) {         System.out.println("Welcome to the Future Value Calculator\n");         Scanner sc...

    public static void main(String[] args) {         System.out.println("Welcome to the Future Value Calculator\n");         Scanner sc = new Scanner(System.in);         String choice = "y";         while (choice.equalsIgnoreCase("y")) {             // get the input from the user             System.out.println("DATA ENTRY");             double monthlyInvestment = getDoubleWithinRange(sc,                     "Enter monthly investment: ", 0, 1000);             double interestRate = getDoubleWithinRange(sc,                     "Enter yearly interest rate: ", 0, 30);             int years = getIntWithinRange(sc,                     "Enter number of years: ", 0, 100);             System.out.println();            ...

  • Explain this java code, please. import java.util.Scanner; public class Program11 { public static void main(String[] args)...

    Explain this java code, please. import java.util.Scanner; public class Program11 { public static void main(String[] args) { Scanner stdIn = new Scanner(System.in); final int maxSize = 128; String[] titles = new String[maxSize]; int[] lengths = new int[maxSize]; int numDVDs = 0; String op; op = menu(stdIn); System.out.println(); while (!op.equalsIgnoreCase("q")) { if (op.equalsIgnoreCase("a")) { if (numDVDs < maxSize) numDVDs = addDVD(titles, lengths, numDVDs, stdIn); } else if (op.equalsIgnoreCase("t")) searchByTitle(titles, lengths, numDVDs, stdIn);    else if (op.equalsIgnoreCase("l")) searchByLength(titles, lengths, numDVDs, stdIn); System.out.println('\n');...

  • Convert into pseudo-code for below code =============================== class Main {    public static void main(String args[])...

    Convert into pseudo-code for below code =============================== class Main {    public static void main(String args[])    {        Scanner s=new Scanner(System.in);        ScoresCircularDoubleLL score=new ScoresCircularDoubleLL();        while(true)        {            System.out.println("1--->Enter a number\n-1--->exit");            System.out.print("Enter your choice:");            int choice=s.nextInt();            if(choice!=-1)            {                System.out.print("Enter the score:");                int number=s.nextInt();                GameEntry entry=new GameEntry(number);   ...

  • My Java code from last assignment: Previous Java code: public static void main(String args[]) { //...

    My Java code from last assignment: Previous Java code: public static void main(String args[]) { // While loop set-up boolean flag = true; while (flag) { Scanner sc = new Scanner(System.in); // Ask user to enter employee number System.out.print("Enter employee number: "); int employee_number = sc.nextInt(); // Ask user to enter last name System.out.print("Enter employee last name: "); String last_name = sc.next(); // Ask user to enter number of hours worked System.out.print("Enter number of hours worked: "); int hours_worked =...

  • I need the following java code commented import java.util.Scanner; public class Main { public static void...

    I need the following java code commented import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner input = new Scanner (System.in); int productNo=0; double product1; double product2; double product3; double product4; double product5; int quantity; double totalsales=0; while(productNo !=0) System.out.println("Enter Product Number 1-5"); productNo=input.nextInt(); System.out.println("Enter Quantity Sold"); quantity=input.nextInt(); switch (productNo) { case 1: product1=1.00; totalsales+=(1.00*quantity); break; case 2: product2=2.00; totalsales+=(2.00*quantity); break; case 3: product3=6.00; totalsales+=(6.00*quantity); break; case 4: product4=23.00; totalsales+=(23.00*quantity); break; case 5: product5=17.00; totalsales+=(17.00*quantity); break;...

  • import java.util.Scanner; import java.util.ArrayList; public class P3A2_BRANDT_4005916 {    public static void main(String[] args)    {...

    import java.util.Scanner; import java.util.ArrayList; public class P3A2_BRANDT_4005916 {    public static void main(String[] args)    {        String name;        String answer;        int correct = 0;        int incorrect = 0;        Scanner phantom = new Scanner(System.in);        System.out.println("Hello, What is your name?");        name = phantom.nextLine();        System.out.println("Welcome " + name + "!\n");        System.out.println("My name is Danielle Brandt. "            +"This is a quiz program that...

  • import java.util.Scanner; public class Client{ public static void main(String args[]){    Coin quarter = new Coin(25);...

    import java.util.Scanner; public class Client{ public static void main(String args[]){    Coin quarter = new Coin(25); Coin dime = new Coin(10); Coin nickel = new Coin(5);    Scanner keyboard = new Scanner(System.in);    int i = 0; int total = 0;    while(true){    i++; System.out.println("Round " + i + ": "); quarter.toss(); System.out.println("Quarter is " + quarter.getSideUp()); if(quarter.getSideUp() == "HEADS") total = total + quarter.getValue();    dime.toss(); System.out.println("Dime is " + dime.getSideUp()); if(dime.getSideUp() == "HEADS") total = total +...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT