Results 1 to 7 of 7
  1. #1
    Koba is offline Member
    Join Date
    Oct 2011
    Posts
    12
    Rep Power
    0

    Default Morse code translation?

    Hey guys,

    So I've been working on a code that allows for a user input of English to translate to morse code and a user input of morse code to translate to English. English to morse was easy enough, but morse to English is proving far more difficult. I'm not quite sure how to designate each morse 'letter' as its own, if you know what I mean. I feel the split method might be useful, because I could split the user input at each space or | character, but I'm not very good with coding a split and I keep getting a bunch of nonsense when I test my code.

    Does anyone have an idea as to what I could do?

  2. #2
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

  3. #3
    Koba is offline Member
    Join Date
    Oct 2011
    Posts
    12
    Rep Power
    0

    Default Re: Morse code translation?

    String m;

    m = Input.getString ( " Type a sentence in morse, separating spaces with a space. " );

    String [] test = m.split(" ");

    for ( int x = 0; x < test.length; x++ )

    System.out.println( " Test is " + test[x] );

    I tested a normal sentence first, like "Morse test", but I got back a bunch of gibberish. Something like [Ljava.lang.String;@16930e2. Perhaps I'm not using it correctly as an array?

  4. #4
    Koba is offline Member
    Join Date
    Oct 2011
    Posts
    12
    Rep Power
    0

    Default Re: Morse code translation?

    This didn't post the first time I tried, so I'll try again:

    String m;

    m = Input.getString ( " Type a sentence in morse, separating spaces with a space. " );

    String [] test = m.split(" ");

    for ( int b = 0; b < test.length; b++ )
    {
    System.out.println( " Test is " + test[b] );
    }

    I'm getting a bizarre [Ljava.lang.String error when I test this. My input, by the way, was "Morse Test". Any ideas? Perhaps I'm not formatting it correctly as an array?

  5. #5
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

  6. #6
    Koba is offline Member
    Join Date
    Oct 2011
    Posts
    12
    Rep Power
    0

    Default Re: Morse code translation?

    [Ljava.lang.String;@16930e2

    It actually says 'Test is' before that, so I know it's a problem with the second part of the print statement.

  7. #7
    Fubarable's Avatar
    Fubarable is offline Moderator
    Join Date
    Jun 2008
    Posts
    19,316
    Blog Entries
    1
    Rep Power
    25

    Default Re: Morse code translation?

    Quote Originally Posted by Koba View Post
    [Ljava.lang.String;@16930e2

    It actually says 'Test is' before that, so I know it's a problem with the second part of the print statement.
    That's not an error message. All that's saying is that Test is an array of String, something we already know.

Similar Threads

  1. Morse Code Java Program - Help Needed Please!!
    By dungeondragon in forum New To Java
    Replies: 8
    Last Post: 02-25-2011, 04:36 AM
  2. Language translation
    By archanaanbu in forum Java Applets
    Replies: 13
    Last Post: 02-19-2011, 06:56 PM
  3. Language translation
    By archanaanbu in forum Java Applets
    Replies: 0
    Last Post: 02-09-2011, 05:21 AM
  4. Morse Code
    By Jamison5213 in forum New To Java
    Replies: 6
    Last Post: 04-14-2010, 04:56 AM
  5. WORD Translation HELP PLZ :(
    By sammypants in forum New To Java
    Replies: 2
    Last Post: 11-24-2009, 01:46 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •