Ok...I am really stumped by this...(Please Help!)

I am new to Dev. Conn. and to programming in Java. I am working on a project for school. I have written this test application to take Morse Code input from a JOptionPane and output the corresponding letters to System.out --- but it does not work. It compiles and accepts input but then just freezes up. Can someone please help? I am not looking for you to do it for me just help me to understand what I am doing wrong. Thank you in advance.
Program Code:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class ArrayTest extends Object
     public static void main(String args[])
          String langKey[] = new String[36];
          String cipherKey[] = new String[36];
          langKey[0] = "A";
          langKey[1] = "B";
          langKey[2] = "C";
          langKey[3] = "D";
          langKey[4] = "E";
          langKey[5] = "F";
          langKey[6] = "G";
          langKey[7] = "H";
          langKey[8] = "I";
          langKey[9] = "J";
          langKey[10] = "K";
          langKey[11] = "L";
          langKey[12] = "M";
          langKey[13] = "N";
          langKey[14] = "O";
          langKey[15] = "P";
          langKey[16] = "Q";
          langKey[17] = "R";
          langKey[18] = "S";
          langKey[19] = "T";
          langKey[20] = "U";
          langKey[21] = "V";
          langKey[22] = "W";
          langKey[23] = "X";
          langKey[24] = "Y";
          langKey[25] = "Z";
          langKey[26] = "0";
          langKey[27] = "1";
          langKey[28] = "2";
          langKey[29] = "3";
          langKey[30] = "4";
          langKey[31] = "5";
          langKey[32] = "6";
          langKey[33] = "7";
          langKey[34] = "8";
          langKey[35] = "9";
          cipherKey[0] = ".-";
          cipherKey[1] = "-...";
          cipherKey[2] = "-.-.";
          cipherKey[3] = "-..";
          cipherKey[4] = ".";
          cipherKey[5] = "..-.";
          cipherKey[6] = "--.";
          cipherKey[7] = "....";
          cipherKey[8] = "..";
          cipherKey[9] = ".---";
          cipherKey[10] = "-.-";
          cipherKey[11] = ".-..";
          cipherKey[12] = "--";
          cipherKey[13] = "-.";
          cipherKey[14] = "---";
          cipherKey[15] = ".--.";
          cipherKey[16] = "--.-";
          cipherKey[17] = ".-.";
          cipherKey[18] = "...";
          cipherKey[19] = "-";
          cipherKey[20] = "..-";
          cipherKey[21] = "...-";
          cipherKey[22] = ".--";
          cipherKey[23] = "-..-";
          cipherKey[24] = "-.--";
          cipherKey[25] = "--..";
          cipherKey[26] = "-----";
          cipherKey[27] = ".----";
          cipherKey[28] = "..---";
          cipherKey[29] = "...--";
          cipherKey[30] = "....-";
          cipherKey[31] = ".....";
          cipherKey[32] = "-....";
          cipherKey[33] = "--...";
          cipherKey[34] = "---..";
          cipherKey[35] = "----.";
          String input ="";
          String output = "";
          int s = 0;
          int i = 0;
          //Get user input
          input = JOptionPane.showInputDialog(
"Enter Morse Code to be Decoded to Plain Text:");
          int length = input.length()- 1;
          while((i != -1) && (i < length))
               i = input.indexOf(" ", s);
                    if(i != -1)
                              String s1 = "";
                              s1 = input.substring(s, i);
                              for( int n = 0; n < cipherKey.length; i++ )
                                   if(s1.equals(cipherKey[n]))
                                        output += langKey[n].toString();
                                        break;
                    if(input.substring(i + 1, i + 2) == " ")
                         output += " ";
                         i++;
                    System.out.println(output);
          System.exit( 0 );
     }//EOMain
}//EOF
Please advise. Thanks again.

Got bored:
import javax.swing.*;
import java.awt.*;
import java.awt.event.*;
import java.util.*;
public class ArrayTest extends Object
  public static void main(String args[])
    HashMap mapMorseToAlpha = new HashMap();
    mapMorseToAlpha.put( ".-", "A" );
    mapMorseToAlpha.put( "-...", "B" );
    mapMorseToAlpha.put( "-.-.", "C" );
    mapMorseToAlpha.put( "-..", "D" );
    mapMorseToAlpha.put( ".", "E" );
    mapMorseToAlpha.put( "..-.", "F" );
    mapMorseToAlpha.put( "--.", "G" );
    mapMorseToAlpha.put( "....", "H" );
    mapMorseToAlpha.put( "..", "I" );
    mapMorseToAlpha.put( ".---", "J" );
    mapMorseToAlpha.put( "-.-", "K" );
    mapMorseToAlpha.put( ".-..", "L" );
    mapMorseToAlpha.put( "--", "M" );
    mapMorseToAlpha.put( "-.", "N" );
    mapMorseToAlpha.put( "---", "O" );
    mapMorseToAlpha.put( ".--.", "P" );
    mapMorseToAlpha.put( "--.-", "Q" );
    mapMorseToAlpha.put( ".-.", "R" );
    mapMorseToAlpha.put( "...", "S" );
    mapMorseToAlpha.put( "-", "T" );
    mapMorseToAlpha.put( "..-", "U" );
    mapMorseToAlpha.put( "...-", "V" );
    mapMorseToAlpha.put( ".--", "W" );
    mapMorseToAlpha.put( "-..-", "X" );
    mapMorseToAlpha.put( "-.--", "Y" );
    mapMorseToAlpha.put( "--..", "Z" );
    mapMorseToAlpha.put( "-----", "0" );
    mapMorseToAlpha.put( ".----", "1" );
    mapMorseToAlpha.put( "..---", "2" );
    mapMorseToAlpha.put( "...--", "3" );
    mapMorseToAlpha.put( "....-", "4" );
    mapMorseToAlpha.put( ".....", "5" );
    mapMorseToAlpha.put( "-....", "6" );
    mapMorseToAlpha.put( "--...", "7" );
    mapMorseToAlpha.put( "---..", "8" );
    mapMorseToAlpha.put( "----.", "9" );
    String strInput = JOptionPane.showInputDialog(" Enter Morse Code to be Decoded to Plain Text:" );
    StringBuffer strbOutput = new StringBuffer();
    if( strInput != null )
      for( StringTokenizer st = new StringTokenizer( strInput ); st.hasMoreTokens(); )
        String strMorseKey = st.nextToken();
        String strAlpha = (String)mapMorseToAlpha.get( strMorseKey );
        if( strAlpha != null )
          strbOutput.append( strAlpha != null ? strAlpha : "#" );
      JOptionPane.showMessageDialog( null, strbOutput.toString() );     
    System.exit( 0 );
}

Similar Messages

  • Playlists, I'm really tired of this please help!

    Please, someone give me a clear answer! I have an IPod Nano which I have had for just over a year, and I have been creating playlists on it for that time. Now, I want all of those playlists, including the purchased one that ITunes created on my new phone, which I got about a month ago, and have been posting this question for a week or so now.

    OK, you have your phone connected to the computer with a cable, you have iTunes open, you have your phone highlighted in the left panel under devices, click on the 'music' selection along the top. In that window you should see the main title of Sync Music - that should be checked, then in the top box on that page there should be 2 options - 1. 'entire music library' or 2. 'selected playlists, artists, albums and genres'.
    Below that should be lists of your playlists, artists, genres, and albums.
    I have checked option 2, and then I have checked the playlists I want to sync to my phone.
    Hope this helps.

  • I have a debit card but would like to download apps from the store. how do I do that? I can't possibly get a credit card just for this. please help.

    Hi,
    I have an iTouch. I'd like to download some free apps. but I have a debit card but would like to download apps from the store. how do I do that? I can't possibly get a credit card just for this. please help.

    I really do not think it is the iPad or your network connection. Other users have reported this very same issue. Try this and see if it works for you - it may not work - but it's easy to try - harmless - and it has worked in the past for others.
    Try signing out of your account and restart your iPad.
    Go to Settings>Store>Apple ID and tap the ID and sign out. Restart the iPad by holding down on the sleep button until the red slider appears and then slide to shut off. To power up hold the sleep button until the Apple logo appears and let go of the button. Go back to Settings>Store> Apple ID and sign in again.

  • I switched to the classic 'landscape' and when i reboot, it just stays at the greay screen, with the macintosh logo, and a blinking question mark. ive tried several methods of key combinations with rebooting etc.. i just bought this. please help.

    i switched to the classic 'landscape' and when i reboot, it just stays at the greay screen, with the macintosh logo, and a blinking question mark. ive tried several methods of key combinations with rebooting etc.. i just bought this. please help.
    I bought this off of craigslist with my christmas money, TODAY. i really need help, i have OS X experience from school, just not OS 9x. I need to reboot back to OS X asap. anything that may help is very appreciated. Thank You.
    Chris.

    Are you able to start up in Safe Mode?
    http://support.apple.com/kb/HT1455?viewlocale=en_US
    If this works you will see the normal desktop Once completely started up in Safe Mode, try to restart normally and go to Applications > Utilities > Disk Utility. Click on the top hard drive icon in the left sidebar and note the S.M.A.R.T. status at the bottom right of the pane. What does it say?
    Select the named boot volume in the left sidebar, ("Macintosh HD" unless it has been renamed). What is the hard drive capacity and how much space remains available on it? Repair permissions on it.
    See if you are able to do a little hard drive maintenance to help things out.

  • My Mac book pro keeps saying "connection time out occurred" I have a 2011 pro with all the latest updates. It keeps doing it and it really annoys me! Please help!

    My Mac book pro keeps saying "connection time out occurred" I have a 2011 pro with all the latest updates. It keeps doing it and it really annoys me! Please help!

    Take each of the following steps that you haven't already tried, until the problem is resolved.
    Step 1
    Restart the router. Many problems are solved that way.
    Step 2
    Change the name of the wireless network, if applicable, to eliminate any characters other than letters and digits. You do that on your router via its web page, if it's not an Apple device, or via AirPort Utility, if it is an Apple device.
    Step 3
    From the menu bar, select
     ▹ System Preferences... ▹ Network
    Click the Assist me button and select Assistant. Follow the prompts.
    Step 4
    Back up all data.
    Launch the Keychain Access application in any of the following ways:
    ☞ Enter the first few letters of its name into a Spotlight search. Select it in the results (it should be at the top.)
    ☞ In the Finder, select Go ▹ Utilities from the menu bar, or press the key combination shift-command-U. The application is in the folder that opens.
    ☞ Open LaunchPad. Click Utilities, then Keychain Access in the icon grid.
    Enter the name of your wireless network in the search box. You should have one or more "AirPort network password" items with that name. Make a note of the name and password, then delete all the items. Quit Keychain Access. Turn Wi-Fi off and then back on. Reconnect to the network.
    Step 5
    You may need to change other settings on the router. See the guidelines linked below:
    Recommended settings for Wi-Fi routers and access points
    Potential sources of interference
    Step 6
    Make a note of all your settings for Wi-Fi in the Network preference pane, then delete the connection from the connection list and recreate it with the same settings. You do this by clicking the plus-sign icon below the connection list, and selecting Wi-Fi as the interface in the sheet that opens. Select Join other network from the Network Name menu, then select your network. Enter the password when prompted and save it in the keychain.

  • Hi all. I have a factory unlocked iphone 4s. I'm from Belize but i'm going to visit Fort Lauderdale, FLA. How can I get data for my phone? I checked the web and only got 'not sure to don't know' answers. Whoever has done this please help me

    Hi All. I live outside of the USA and have an iPhone 4s. I'm going to Fort Lauderdale, FLA and want to data service for my iPhone ( navigation using google or imaps, browsing and voip ing when no wi fi available). I browsed the net but seems almost impossible. When I visited Toronto I was able to get data thru Koodo but I don't think this is offered in the USA. Anyone who has real experience with this please help. This is a situation that is best aided by persons who have experienced it. Thanks

    Have a look here:
    http://forums.macrumors.com/archive/index.php/t-982315.html

  • Hello! I was on my Mac and then I clicked on iTunes. Then I clicked on iTunes, and accidentally removed my device from my Mac, how can I get it back? Also when I plug my iPod into the computer, it downloads everything, how can I stop this. please help!thx

    Hello! I was on my Mac and then I clicked on iTunes. Then I clicked on Account, and accidentally removed my device from my Mac, how can I get it back? Also when I plug my iPod into the computer, it downloads everything that is on my computer, how can I stop this. please help! please help!!!!!!thank you

    Is the iPod still singed into the account isn Settings>iTunes and App Stores and SettingsZ>iCloudl? If it is then I would not be concerned.
    Also see:
    iTunes Store: Associating a device or computer to your Apple ID
    since you may have started the 90 day window.
    For the other "problem", go to iTunes>Preferences>Devices and check the box that says Prevent iPod....automatically syncing.

  • I'm unable to play game in hp 15-r009TU.. what can i do for this. please help me for this

    i'm unable to play game in hp 15-r009TU.. what can i do for this. please help me for this

    Hi Madhuama, I'll try to give you a hand with this. First off, what OS is running on your notebook, what game are you attempting to play, and how is it not working? Is it not installing?
    Thanks,
    Fenian Frank
    I work on behalf of HP

  • In Siri, I can call by my voice, but why I can not use Siri voice call in my country (Laos), just can call only us phone number; my country we use like 3 number for option call, 8 numbers for call friend but Siri cannot use this please help us, thanks

    In Siri, I can call by my voice, but why I can not use Siri voice call in my country (Laos), just can call only us phone number; my country we use like 3 number for option call, 8 numbers for call friend but Siri cannot use this please help us, thanks
    And please help me can type Laos font in it like andrio phone.

    Hi Cozumel,
    Thanks for posting. I'm sorry you're having problems with your bills. I can take a look at this for you. Drop me an email with your account details and a link to this thread for reference. You'll find the address in my profile.
    Cheers
    David
    BTCare Community Mod
    If we have asked you to email us with your details, please make sure you are logged in to the forum, otherwise you will not be able to see our ‘Contact Us’ link within our profiles.
    We are sorry but we are unable to deal with service/account queries via the private message(PM) function so please don't PM your account info, we need to deal with this via our email account :-)

  • In Linux, my firefox uses the /etc/firefox profile for all users, now I need ONE user only to start with their own profile, I'm struggling to achieve this, please help!

    In Linux, my firefox uses the /etc/firefox profile for all users, now I need ONE user only to start with their own profile, I'm struggling to achieve this, please help!

    .Jake. wrote:
    I forgot to say that the hard drive has not been used yet...
    So you have no backup of your data at all?
    Pete

  • When i update my iphone it say error 1015 what is this please help me

    when i update my iphone it say error 1015 what is this please help me

    Error 1015: This error is typically caused by attempts to downgrade the iPhone, iPad, or iPod touch's software. This can occur when you attempt to restore using an older .ipsw file. Downgrading to a previous version is not supported. To resolve this issue, attempt to restore with the latest iPhone, iPad, or iPod touch software available from Apple. This error can also occur when an unauthorized modification of the iOS has occurred and you are now trying to restore to an authorized, default state.
    http://support.apple.com/kb/TS3694#error1015.

  • I have just got my iPad I have created Apple ID and it is asking me to verify my account at my Apple ID address but I can't find where I need to do this please help

    I have just got my iPad and have created my Apple ID and it is asking me to verify my account and that it has been sent to my Apple ID address but I cannot find where I need to be to do this please help

    I have my Apple ID but they sent verify to my personal email account which I went on the link but like I said when I try to use my iTunes or App Store it states I have not verified my apple id and I don't know what else to do

  • I am unable to download Acrobat XI Standard purchased 19Feb15 & unable to locate on your web site simple steps to do this - please help; what am I not doing?

    I am unable to download Acrobat XI Standard purchased 19Feb15 & unable to locate on your web site simple steps to do this - please help; what am I not doing?

    Make sure you have cookies enabled and clear your cache.  If it continues to fail try using a different browser.

  • I just recently got my I phone five and none of my soundsh are working as to ringing notifications etc. what can I do to fix this please help me

    I just recently got my I phone five and none of my sounds are
    working as to ringing notifications etc.
    what can I do to fix this please help me

    You are sure the mute switch is not on?
    The mute switch is at the left side above the volume buttons. If it's red/orange then mute is on.

  • I m not able to connect for the wifi  which i have used earlier ,i m getting an error as unable to join the network how to resolve this please help me

    i m not able to connect for the wifi  which i have used earlier ,i m getting an error as unable to join the network how to resolve this please help me

    We were able to log in this morning and all is working. You should be able to log in at any point today. Please let us know if you are having any other difficulties.

  • Ok so I use an hdmi connector on my iPhone 4S to watch netflix. But after I updated to iOS 7 it will not work my tv doesn't receive a signal. Does anyone have any insure to this please help .!.!.

    Ok so I use an hdmi connector on my iPhone 4S to watch netflix. But after I updated to iOS 7 it will not work my tv doesn't receive a signal. Does anyone have any insure to this please help .!.!.

    The 8 pin Lightning connector can only output 720p and lacks all iPod Out functionality unlike the full iPod Out functionality and 1080p that the 30 pin connector has and I suspect that they are coding iOS 7 specifically for the new devices which have severely reduced abilities and perhaps skipping adding the code needed for 30 pin devices to use their functionality with HDMI, etc.

Maybe you are looking for

  • Can I format and use a Hard Drive for my mac if removed from a Desk Top PC

    Hi All, I wondered if you can help with some advise. I have a mackbook and love it, will never go back to pc. But, I have a desk top pc with a fairly sizable Hard Drive in it. Even though I also have a WD external Hard Drive for my macbook back up, w

  • General question on SQL Server 2000 to Oracle 10g

    Hello all, I just have a general question on migration from SQL Server 2000 to Oracle 10g using SQL Developer. How does it migrate Users with proper privileges from SQL Server to Oracle? Follow the interface steps? Or should the users be created on d

  • After maverick upgrade on MacBook Pro computer won't boot

    How do I get it to boot Is there a safe mode Can I revert back to my old system It finished installing launched started working on it then it started not seeing files and getting errors System extensions were not installed correctly contact developer

  • Having trouble having both an interactive form and an interactive page curl in a pdf?

    Okay, so I need an interactive pdf with a page curl AND an interactive form. I exported my Indesign file as a swf file with the interactive page curl, (which the interactive form doesn't work on), then I imported the swf file back into Indesign, open

  • Help convert HWS to LVM

    Hey, I'm a student at the University of New Hampshire. After talking with an NI Engineer for a while I found out that the equipment here is not capable of converting my hws files to lvm. Could someone with a newer version of LabView or any other meth