Encoding program help

Hello I am trying to make a program to encode or decode an array. I have gotten it to work but only by making many if statements but I don't want it to be that ugly. I am fairly new to programming and am having trouble with the
this method is the one I am having the trouble with It is supposed to compare find thisChar in the encoder array and then convert that to two characters down the array. I know it is not right and I am getting the out of bounds error. If someone could help me solve this I would appreciate it.
      char charMapEnco(char thisChar)
        for (int index =0; index < encoder.length; index++)
           if (thisChar == encoder[index])
               thisChar = encoder[index + 2];
         return thisChar;
        Here is the whole code
public class EncodeDecode
    //Input list of numbers/letters
    private String[] originalList;  
    //Resulting list of encoded numbers/letters
    private String[] encodeList;
    //Resulting list of decoded numbers/letters
    private String[] decodeList;
    private char[] encoder = {'A','B','C','D','E','F','G','H',
        'I','J','K','L','M','N','O','P','Q','R','S','T','U','V',
        'W','X','Y','Z','a','b','c','d','e','f','g','h',
        'i','j','k','l','m','n','o','p','q','r','s','t','u','v',
        'w','x','y','z','0','1','2','3','4','5','6','7','8','9'};
    public EncodeDecode(String[] origList)
        //Assign parameter to instance variable
        originalList = origList;
        //Create another string array of the same size
        encodeList = new String[originalList.length];
        //Do the mapping
        for (int index = 0; index < originalList.length; index++)
            encodeList[index] = encodeConverter(originalList[index]);  
     //Create another string array of the same size
        decodeList = new String[encodeList.length];
        //Do the mapping
        for (int index = 0; index < encodeList.length; index++)
            decodeList[index] = decodeConverter(encodeList[index]);  
    String encodeConverter(String origMix)
        //Start with empty result string
        String result = "";
        //for each character in the origMix
        for (int index = 0; index < origMix.length(); index++)
            //map it to correct number/letter and concat it to the result
            result = result + charMapEnco(origMix.charAt(index));
        //return result string
        return result;
    String decodeConverter(String encoMix)
        //Start with empty result string
        String result = "";
        //for each character in the encoMix
        for (int index = 0; index < encoMix.length(); index++)
            ////map it to correct number/letter and concat it to the result
            result = result + charMapDeco(encoMix.charAt(index));
        //return result string
        return result;
     * This maps one character to one number/letter using the standard
     * mapping. Any chars other than numbers, uppercase or lowercase
     * letters, will be flagged as errors and left unchanged
      char charMapEnco(char thisChar)
        for (int index =0; index < encoder.length; index++)
           if (thisChar == encoder[index])
               thisChar = encoder[index + 2];
         return thisChar;
     * This maps one characeter to one number/letter using the standard
     * mapping. Any chars other than numbers, uppercase or lowercase
     * letters, will be flagged as errors and left unchanged
   char charMapDeco(char thisChar)
    //Get all three lists:
    String[] getEncodeList()
        return encodeList;
    String[] getDecodeList()
        return decodeList;
    String[] getOriginalList()
        return originalList;
}Edited by: ebuffh51 on Feb 5, 2008 8:27 PM

Here's some code to play with
public class Test{
  private static char[] decoded = {'A','B','C','D','E','F','G','H',
        'I','J','K','L','M','N','O','P','Q','R','S','T','U','V',
        'W','X','Y','Z','a','b','c','d','e','f','g','h',
        'i','j','k','l','m','n','o','p','q','r','s','t','u','v',
        'w','x','y','z','0','1','2','3','4','5','6','7','8','9'};
  private char[] encoded;
  public Test(int offset){
    this.encoded = new char[decoded.length];
    System.arraycopy(Test.decoded,0,this.encoded,offset,this.encoded.length-offset);
    System.arraycopy(Test.decoded,Test.decoded.length-offset,this.encoded,0,offset);
  public String encode(String toencode){
    StringBuffer encoded = new StringBuffer();
    for(int i=0;i<toencode.length();i++){
         encoded.append(encodeChar(toencode.charAt(i)));
    return encoded.toString();
  public String decode(String todecode){
    StringBuffer decoded = new StringBuffer();
    return decoded.toString();
  private char encodeChar(char toencode){
    for(int i=0;i<Test.decoded.length;i++){
         if(toencode==Test.decoded){
          return this.encoded[i];
return toencode;
/*private char decodeChar(char todecode){
public static void main(String args[]){
Test t = new Test(7);
String sample = "ABCDEFGHIJKLMNOPQRSTUVWXYZ!?abcdefghijklmnopqrstuvwxyz123456789";
System.out.println("Sample before "+sample);
sample = t.encode(sample);
System.out.println("Sample encoded "+sample);
sample = t.decode(sample);
System.out.println("Sample decoded "+sample);

Similar Messages

  • ERROR - PDE-PEP006 ENCODED PROGRAM UNIT HAS A UNKNOWN FORMAT

    I am learning Developer 2000. After attaching talbotstandar.pll library, when I try to expenad Set_Up_List procedre, I am getting this error "ERROR - PDE-PEP006 ENCODED PROGRAM UNIT HAS A UNKNOWN FORMAT". Because of this I am not able to proceed, please give me soution to get rid of this problem as soon as possible.
    My email is [email protected]

    ERROR - PDE-PEP006 ENCODED PROGRAM UNIT HAS A UNKNOWN FORMAT
    Hai friends
    i have a form developed in forms 10g and reports 10g.
    the same form when i when iam trying to open in forms 6i/reports6i,everything is getting(layout) but when i am trying to see code it was blank. why.
    can anybody help to solve this problem or can any body give me the solutions to my email
    thanks
    vas
    E-mail :[email protected]

  • When i open itunes its normal and then out of nowhere it says "itunes has stopped working" and i have to click 'close program'. help?

    when i open itunes its normal and then out of nowhere it says "itunes has stopped working" and i have to click 'close program'. help?

    Having the same issue here....a quick fix is to just minimize the window, and immediately maximize it.  It will now fit the screen.  Trouble is, after you close it, you'll have to do it again when you re-start itunes.  The good news is it takes all of about 2 seconds.  Apple should fix this.  Should.

  • Programming help - how to get the read-only state of PDF file is windows explorer preview is ON?

    Programming help - how to get the read-only state of PDF file is windows explorer preview is ON?
    I'm developing an application where a file is need to be saved as pdf. But, if there is already a pdf file with same name in the specified directory, I wish to overwrite it. And in the overwrite case, read-only files should not be overwritten. If the duplicate(old) file is opened in windows (Win7) explorer preview, it is write protected. So, it should not be overwritten. I tried to get the '
    FILE_ATTRIBUTE_READONLY' using MS API 'GetFileAttributes', but it didn't succeed. How Adobe marks the file as read-only for preview? Do I need to check some other attribute of the file?
    Thanks!

    Divya - I have done it in the past following these documents. Please read it and try it it will work.
    Please read it in the following order since both are a continuation documents for the same purpose (it also contains how to change colors of row dynamically but I didnt do that part I just did the read_only part as your requirement) 
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/f0625002-596c-2b10-46af-91cb31b71393
    http://www.sdn.sap.com/irj/scn/go/portal/prtroot/docs/library/uuid/d0155eb5-b6ce-2b10-3195-d9704982d69b?quicklink=index&overridelayout=true
    thanks!
    Jason PV

  • Freely Programmed help in Pop Up Window

    Hi,
      Is it possible to display the data of freely programmed help in the pop up window.
    Thanks
    Raghavendra

    Hi Thomas,
       I agree that by using Freely Programmed help the data will be displayed in a seperate window. I want to display the data in a window( of type Pop Up) because i am displaying table control with 3 fields on clicking f4 and it has 2 buttons Ok and Cancel. But if there are 50 entries the user needs to scroll down to click on Ok. If the window is of type pop up Ok button will be embedded in the window instead of on view.
    Thanks
    Raghavendra

  • Freely programmed help in ALV

       HI:ALL
          How to achieve  Freely programmed help in ALV?

    Hi,
    On APPLY buttton action, write the below code
    *Fire the event to indicate that data selection is done
    wd_comp_controller->fire_vh_data_selected_evt( ).
    wd_comp_controller->value_help_listener->close_window( ).
    *Raise Event
       cl_fpm_factory=>get_instance( )->raise_event_by_id( EXPORTING   iv_event_id   = '<custom event name>').
    And in PROCESS_EVENT of your webdynpro component(where Freely Programmed search help is implemented) write the code as per your requirement to set the values back to the table.
    CASE IO_EVENT->MV_EVENT_ID.
              WHEN '<CUSTOM EVENT NAME>'.
                        write code as per your requirement.
    ENDCASE.
    Thanks
    KH

  • N95 Maps Program Help and Suggestions Anybody??

    N95 Maps Program Help and Suggestions Anybody??
    havnt updated to firmware v12 yet
    Why can't I search my Address or Current Location and then save this as HOME or say my Start_Point_01?
    I have managed to save my HOME as a PEOPLE LOCATION and my friends address etc and worked out
    how to plan a route etc, BUT Maps GPS POSITION thinks I live 20 miles away??
    I dont seem to be able to simply set my HOME or Current Location myself,
    I have seen some Satelite activity but insists I live 20 miles away :/ how do I fix this,
    it's realy annoying. any handy tips people??
    cant upgrade firmware as need phone plugged into wall socket
    at webcafe, will have to wait for firmware :/
    N95-1 (8GB-MicroSD),LCG-Audio,Fring,Nimbuzz,Skype,Youtube,iPlayer,Garmin4-GPS.Googlemaps,SkyFire,ZoneTag,Gravity, Sennheiser CX-400-IIs,500-IIs,TR-120 Wireless,HD215'S.AudioTechnica ATX-M50's.BT B-Tube BT Speaker.

    The least problems you'll have with miniDV cameras. About any miniDV camera will connect to a Mac via Firewire. HDD cameras are an open invitation to trouble, especially as you speak of older computers.
    There are well-featured models out there now for 2-300 bucks. But watch out for cameras that connect to the computer via a dock. I had two Sony with these @#$% docking stations .... both docks broke and rendered the cameras useless for capturing. replacing the dock was nearly the price of a new cam.

  • What Is Wrong With My Program Help

    This Is The Assignment I Have To Do:
    Write a Java program that prints a table with a list of at least 5 students together with their grades earned (lab points, bonus points, and the total) in the format below.
    == Student Points ==
    Name Lab Bonus Total
    Joe 43 7 50
    William 50 8 58
    Mary Sue 39 10 49
    The requirements for the program are as follows:
    1.     Name the project StudentGrades.
    2.     Print the border on the top as illustrated (using the slash and backslash characters).
    3.     Use tab characters to get your columns aligned and you must use the + operator both for addition and string concatenation.
    4.     Make up your own student names and points -- the ones shown are just for illustration purposes. You need 5 names.
    This Is What I Have So Far:
    * Darron Jones
    * 4th Period
    * ID 2497430
    *I recieved help from the internet and the book
    *StudentGrades
      public class StudentGrades
         public static void main (String[] args )
    System.out.println("///////////////////\\\\\\\\\\\\\\\\\\");
    System.out.println("==          Student Points          ==");
    System.out.println("\\\\\\\\\\\\\\\\\\\///////////////////");
    System.out.println("                                      ");
    System.out.println("Name            Lab     Bonus   Total");
    System.out.println("----            ---     -----   -----");
    System.out.println("Dill             43      7       50");
    System.out.println("Josh             50      8       58");
    System.out.println("Rebbeca          39      10      49");When I Compile It Keeps Having An Error Thats Saying: "Illegal Escape Character" Whats Wrong With The Program Help Please

    This will work exactly as you want it to be....hope u like it
         public static void main(String[] args)
              // TODO Auto-generated method stub
              System.out.print("///////////////////");
              System.out.print("\\\\\\\\\\\\\\\\\\\\\\\\");
              System.out.println("\\\\\\\\\\\\\\");
              System.out.println("== Student Points ==");
              System.out.print("\\\\\\\\\\\\\\");
              System.out.print("\\\\\\\\\\\\");
              System.out.print("\\\\\\\\\\\\");
              System.out.print("///////////////////");
              System.out.println(" ");
              System.out.println("Name Lab Bonus Total");
              System.out.println("---- --- ----- -----");
              System.out.println("Dill 43 7 50");
              System.out.println("Josh 50 8 58");
              System.out.println("Rebbeca 39 10 49");
         }

  • Freely Programed Help for select-option field

    Hi,
    how can i set freely programmed help for select option field, i mean while adding selection field what are the parameters that are important for freely programmed help.
    i have implemented iwd_value_help in one component comp1 and declared the usage of comp1 in comp2 where i actually defined the usage of select-option component.
    i used parameter   i_value_help_type = if_wd_value_help_handler=>co_prefix_appldev while adding selection field, however when i presss F4 icon, the following message is coming
    View WD_VALUE_HELP does not exist within the component WDR_SELECT_OPTIONS
    Please suggest where i am doing wrong??
    Edited by: kranthi kumar on Dec 29, 2010 6:19 PM

    >
    kranthi kumar wrote:
    > Hi,
    >
    > how can i set freely programmed help for select option field, i mean while adding selection field what are the parameters that are important for freely programmed help.
    >
    > i have implemented iwd_value_help in one component comp1 and declared the usage of comp1 in comp2 where i actually defined the usage of select-option component.
    >
    > i used parameter   i_value_help_type = if_wd_value_help_handler=>co_prefix_appldev while adding selection field, however when i presss F4 icon, the following message is coming
    >
    > View WD_VALUE_HELP does not exist within the component WDR_SELECT_OPTIONS
    >
    > Please suggest where i am doing wrong??
    >
    > Edited by: kranthi kumar on Dec 29, 2010 6:19 PM
    Hi Kranthi,
    Please help me to understand your design.
    Why would you like to create a Freely programmed value help for select-option?. why not use wdr_select_option directly ?

  • Why i cant open the ae after i download ~then pop up something like ae error, crash in program~help~pls

    why i cant open the ae after i download ~then pop up something like ae error, crash in program~help~pls

  • PDE-PEP006 Encoded Program unit has an unknown format.

    Hi All:
    I am using Form builder [32 Bit] Version 6.0.8.23.2 with Oracle 10g.
    I tried to open a form in form builder which is also created in Form 6i, system return following error:
    PDE-PEP006 Encoded Program unit has an unknown format.
    and form opened, but the coding of all triggers, and program units was not there, although the triggers and program units exists and can be seen but without coding.
    Please also tell me can I convert the form into text format thru command prompt?
    What could be the reason?
    Thanks
    Hassan

    Francois
    The only way to get the "new" pl/sql code is to open
    the new version and copy the code, then paste it in
    the old version's builder.
    You mean to say that open the new version form in new version builder? or in old version?
    Thanks
    Hassan

  • Error during rendering/encoding -- PLEASE HELP!!

    Hey everybody!! After trying twice to burn this project to DVD, I'm about ready to rip my hair out!! First of all, here's the specifics about my computer:
    Mac OS 10.3.7 / 800 MHZ Power PC G4 / 256 MB SDRam / My programs are iMovie 4 and I have iDVD5
    OK, I'm trying to burn a movie that is about 1 hour, 23 minutes long. Even though my movie is not 90 minutes long, iDVD does tell me that it is too long and that I need to click on "Best Performance" in my iDVD Preferences. No problem, I did that. (By the way, at the time of the burning, I have about 5.1 GB on space left on my hard drive.)
    Before burning I do repair permissions and delete my "com.apple.idvd.plist".
    So, it burns and burns for roughly 6 hours. Right at the very end, the disk spits out and an error message comes up saying:
    Encoding Video
    Error during rendering/encoding:
    This is very frustrating because I need to get this video done by tonight and turn it in by Monday morning!!
    Any suggestions?? Please help!!! Thanxx!!

    I have about 5.1 GB on space left on my hard drive
    I don't think that's enough. Remember a DVD is 4.7GB (which iDVD first stores on your hard drive) plus temporary files that iDVD needs.

  • My decoding/encoding program that almost works.  What's wrong?

    I've been working on the following program. After it prompts the user to enter a "code," it is then supposed to examine it and either encode or decode it, depending on what the user entered. All entries from the user that are meant to be decoded need to be inputted in this form: "lkdhe lakdh idhal" (1 space after every five letters, and it can only consist of lower or uppercase letters and the numbers 1-5).
    If anything else is entered by the user, the program will encode it. However, I can only get the program to call the encode function, the decode function only comes up when I enter in 1 letter to the console. I'm pretty sure the problem is concerning this loop which is suppose to test to see if the user entered in anything other than a letter or number. I don't think it's doing what I want it to do though. I have another loop to test for the required spaces, and I know that one is working.
    for(n = 0; n <= s.length() ;n++)
              s1 = s.substring(n);
              if(Code.CODE1.indexOf(s1) == -1)
                   return false;
         }Here is the rest of the code:
    import java.util.Scanner;
    public class Enc1
    public static void main (String []args)
         //String message = args[0];
         //String codedMessage = args[1];
         boolean valid = false;
         int i;
         int j;
         Scanner keyboard = new Scanner(System.in);
        System.out.println("Enter a code");
        String code = keyboard.nextLine();
         System.out.println(code);
         if (isCoded(code))
              System.out.println(decode(code));
         else
              System.out.println(encode(code));
    public class Code{
         private static final String CODE1 = "HTNZUL5m3lDQchenpIuORws1jPgVtzKWbfBxXSArdayCJkvqGiF2YoM4E";
         public static final String CODE2 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz ,.;:";
        public static String encode (String message)
              message = "Encode called";
              return message;
             //CODE1.charAt(0);  //0 will equal H
             //CODE1.indexOf(CODE1, 0); //Not sure what it returns
        public static String decode (String codedMessage)
              codedMessage = "Decode called";
              return codedMessage;
         public static boolean isCoded(String s){
         int n;
         int m;
         boolean valid = true;
         String s1;
         for(n = 0; n <= s.length() ;n++)
              s1 = s.substring(n);
              if(Code.CODE1.indexOf(s1) == -1)
                   return false;
         for(m = 5; m <= s.length()-1; m = m+6)
                   if(s.charAt(m) == ' ')
                         valid = true;
                   else
                   return false;
         return valid;
        }Any suggestions? I hope I explained my problem clearly enough, I'm a little burnt out on this program, I've been working on it for hours. Any help would be greatly appreciated.

    Hey Bud,
    I think it wouldnt be really clean to mention
    boolean valid = true;in the beginning of your for and if.
    I would personally start of by making my booleans false in the beginning and changing it on logic.
    HTH

  • I recently updated my iTunes to version 10.3.1.55 and when i launch the program it says 'iTunes has stopped working' then another window pop up saying me to close program.HELP!!! ME PLEASE!!

    ok i installed new iTunes version 10.3.1.55 and when i launch itunes it says 'iTunes has stopped working' i get to my problem history this is whay i found
    Problem signature
    Problem Event Name:          APPCRASH
    Application Name:          iTunes.exe
    Application Version:          10.3.1.55
    Application Timestamp:          4deec351
    Fault Module Name:          MediaToolbox.dll
    Fault Module Version:          1.0.694.7
    Fault Module Timestamp:          4ddeb575
    Exception Code:          c0000005
    Exception Offset:          00250000
    OS Version:          6.0.6002.2.2.0.768.3
    Locale ID:          1033
    Additional Information 1:          fd00
    Additional Information 2:          ea6f5fe8924aaa756324d57f87834160
    Additional Information 3:          fd00
    Additional Information 4:          ea6f5fe8924aaa756324d57f87834160
    PLEASE HELP ME!!!!

    Fault Module Name:          MediaToolbox.dll
    Fault Module Version:          1.0.694.7
    Taken at face value, you're having trouble with an Apple Application Support program file there. (Apple Application Support is where single copies of program files used by multiple different Apple programs are kept.)
    Let's try something relatively simple first. Restart the PC. Now head into your Uninstall a program control panel, select "Apple Application Support" and then click "Repair".
    If no joy after that, try the more rigorous uninstall/reinstall procedure from the following post:
    Re: I recently updated to vista service pack 2 and I updated to itunes 10.2.1 and ever since I did that my itunes won't open any more.  Itunes starts but before anything loads a window pops up saying that the prograam has encountered a problem and sh...

  • Links in Windows (7, 64-bit) doesn't open, getting error:" [link] Can't find the program", help!?

    Everytime I click a link that's not in the actual browser window, could be from a word doc, pdf-file or just plain info link in windows gadgets, I get an error:
    [Clicked link]
    Can't find the program
    I have:
    Windows 7 64-bit
    Firefox 4 RC 1
    Firefox is standard browser and installed at default location.
    please help, it's getting really annoying!!

    This is what I get when opening a link from Outlook 2010.
    Windows 7 64bit
    Firefox 4 RC
    Firefox 4 is set as the default browser
    Links won't open in FF4 from any external programs (tweetdeck, outlook, word, etc.)

Maybe you are looking for

  • HP Laserjet M1212nf MFP not printing doc in Windows print queue

    Printer is connected via USB to a laptop running XP. Prints OK. Have another Windows laptop connected via wireless network, sharing the printer and this prints OK. Am trying to share the printer with a Mac OSX Lion over the wireless network. I can ge

  • New MacBook to buy ...

    Hi there !!! I have an iMac at home and I'm completely satisfied with it, but I am in need of a laptop and I am between the MacBook 1.83 GHz and the 2.0 GHz (both white). If I am not wrong, the only difference would be the speed of the processor and

  • Black page background flashes grey when zooming on images

    When I'm previewing my book on iPad I see that when I zoom in on an image (single image gallery widget) the page background which is black flashes grey momentarily. This happens on ipad but not when I preview on the mac. Seems like the page wants to

  • Making a complex text editor.

    I put together a text editor that has all of the basic functions cut, copy, paste, save, open, and some other stuff. Here is the problem: I want to make it so it can display several different fonts, font sizes, and font colors, at once. I have a feel

  • GoToAndStop problem in AIR but not in Flash Player 10

    Hi, I'm currently developing a login screen for users to acces my application. For the login I have 3 frames, frame 1 allows the user to view the assessor login form or the client login form. Depending on which button they select the function "gotoAn