Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8678985
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T20:51:33+00:00 2026-06-12T20:51:33+00:00

I am having a few problems with this build. First it is not all

  • 0

I am having a few problems with this build. First it is not all it will not load the main class. Second I need the user to input their choice of music and then I need the compiler to print selection. Can someone help me with this code? Please excuse me but I am totally new to programming.

public class music {

public static void music(String[] args) {

    System.out.println("What's your favorite kind music?: ");
    System.out.println("1. Country");
    System.out.println("2. Rock");
    System.out.println("3. Heavy Metal");
    System.out.println("4. Folk");

    try{
    BufferedReader bufferRead = new BufferedReader(new InputStreamReader(System.in));
    int s = Integer.parseInt(bufferRead.readLine());
        switch(s){
            case 1:
                System.out.println("Country");
                break;
            case 2:
                System.out.println("Rock");
                break;
            case 3:
                System.out.println("Heavy Metal");
                break;
            case 4:
                System.out.println("Folk");
                break;
            default:
                System.out.println("Country");
                break;
      }



}catch(IOException e){
        e.printStackTrace();
    }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T20:51:35+00:00Added an answer on June 12, 2026 at 8:51 pm

    Solution

    The problem with the source as posted is that you do not have an entry point to your class (i.e. a method called main).

    Suggestions

    Since you mentioned you are also new to programming, I’ve taken the liberty to include some stylistic suggestions to make your code simpler and easier to read (IMO):

    import static java.lang.System.in;
    import static java.lang.System.out;
    
    import java.util.LinkedHashMap;
    import java.util.Map;
    import java.util.Map.Entry;
    import java.util.Scanner;
    
    public class Music {
    
        private static final String DEFAULT_MUSIC = "Country";
    
        public static void main(String[] args) {
            Map<Integer, String> musicOptions = new LinkedHashMap<Integer, String>();
            musicOptions.put(1, DEFAULT_MUSIC);
            musicOptions.put(2, "Rock");
            musicOptions.put(3, "Heavy Metal");
            musicOptions.put(4, "Folk");
    
            out.println("What's your favorite kind music?: ");
            for (Entry<Integer, String> option : musicOptions.entrySet()) {
                Integer choice = option.getKey();
                String music = option.getValue();
    
                out.printf("%d. %s\n", choice, music);
            }
    
            final int choice = new Scanner(in).nextInt();
            String music = musicOptions.get(choice);
            if (music == null) {
                music = DEFAULT_MUSIC;
            }
    
            out.println(music);
        }
    
    }
    

    Further Reading

    http://docs.oracle.com/javase/1.5.0/docs/guide/language/static-import.html
    http://docs.oracle.com/javase/7/docs/api/java/util/Scanner.html#nextInt()
    http://docs.oracle.com/javase/tutorial/java/nutsandbolts/op2.html

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

So I am having a few problems with settings this up. Let me explain.
Good morning all, I'm having a few problems with a method in my C#
First of all I am in DESPERATE need of help here PLEASE I will
I am having a few problems trying to return a table from a SQL
I've been having a few problems running PHP-based utilities within the command line ever
hi I'm having a few problems understanding how to control my listeners in bulk.
I've set up django with haystack but im having a few problems. I have
I have a few classes and I am having problems accessing properties defined in
I'm having problems with google maps, drawing icons was working fine few weeks ago
I'm having a few problems with an application that integrates sharepoint, SQL reporting services

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.