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

  • Home
  • SEARCH
  • 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 6781949
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T16:41:01+00:00 2026-05-26T16:41:01+00:00

First, my code (It is far from perfect, I don’t really know what I

  • 0

First, my code (It is far from perfect, I don’t really know what I am doing) is this:

   public enum Chord { MAJOR, MINOR, DIMINISHED, BASS, BASS2 }
   public enum Scales { C, D, E, F, G, A }
public class EnumTest
{
Chord chord;
public EnumTest(Chord chord)
{
    this.chord = chord;
}
public void tellItLikeItIs()
{

switch (chord) {

    case MAJOR:
            for(Scales C : Scales.values())
                System.out.println(C + " " + C.ordinal());
                break;

//I've tried in the CHORD enum going MAJOR(0, 2, 4) but I don't think that was correct
    case MINOR: System.out.println("C, Eb, G");
                break;
    default:
        System.out.println("I screwed up");
        break;

}
}


public static void main(String[] args)
{

EnumTest firstDay = new EnumTest(Chord.MAJOR);
firstDay.tellItLikeItIs();
EnumTest thirdDay = new EnumTest(Chord.MINOR);
thirdDay.tellItLikeItIs();
System.out.println("Here are all Scale degrees" +
                   " and their ordinal values: ");
for(Scales C : Scales.values())
  System.out.println(C + " " + C.ordinal());



}

}

I might be missing a few brackets and things, I had trouble posting some of it using the code tool. My question is, for case MAJOR, I can get the compiler to print C 0, D 1, E 2, etc.. except I only want it to print C, E and G (0, 2, 4). Is there a way to select ONLY these 3 ordinal values for a major chord and print those?

Also, in the Scales enum I also need the sharps (C, C#, D, D#..) except the sharps are ‘illegal characters’ and I get _MusicChord\Scales.java:2: illegal character: \35 I tried to look into escape characters, but I either didn’t understand the article I read or I was looking at the wrong thing. Could someone also tell me how to add the #’s into the Scales class without them being illegal characters? Any help is appreciated

  • 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-05-26T16:41:02+00:00Added an answer on May 26, 2026 at 4:41 pm

    In the following example you can see how you could address some of the problems you are facing:

    public class EnumTest
    {
        public enum Chord
        {
            MAJOR,
            MINOR,
            DIMINISHED,
            BASS,
            BASS2
        }
    
        public enum Scales
        {
            C("C"),
            CSharp("C#"),
            E("E"),
            F("F"),
            G("G"),
            A("A");
    
            private final String printName;
    
            Scales(String printName)
            {
                this.printName = printName;
            }
    
            public String getPrintName()
            {
                return printName;
            }
    
            public String toString()
            {
                return printName;
            }
    
            private static final Map<Chord, List<Scales>> scalesForChord;
    
            static
            {
                scalesForChord = new HashMap<Chord, List<Scales>>();
    
                scalesForChord.put(Chord.MAJOR, Arrays.asList(Scales.C, Scales.E, Scales.G));
            }
    
            public static List<Scales> getScalesForChord(Chord chord)
            {
                return scalesForChord.get(chord);
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

This is what I have as far as code, it is in the first
Code first: '''this is main structure of my program''' from twisted.web import http from
This is my code so far: The HTML: <form> <label>First Name</label> <input type=text class=first
I have an AXIS2/JAX-WS web service using a code first implementation (yes I know,
First point: I'm not a C++ expert, far from it. I glanced at it
In my code-first setup, I prefer not to allow the consumer (in this case
I got this code I've been working on so far, it is going to
First of all, I know this is a bad solution and I shouldn't be
Which one below is correct? First code has no quotes in the $_GET array
I got the problem that the if-statement doesn't work. After the first code line

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.