Results 1 to 3 of 3
  1. #1
    mustachMan is offline Member
    Join Date
    Dec 2009
    Rep Power

    Default Adding letters to arrays??

    I am trying out these little crack the code programs and at one point there is a function that adds letter to the array then gets the modulo? i have no idea what it is doing.
    Java Code:
    char strarr[] = guess.toCharArray();
    		for (int i=0; i<strarr.length; i++) 
    			strarr[i] = (char)((strarr[i]-'A'+9)%26+'A');
    the array is : "CQXVJBSNOONABXW"

  2. #2
    al_Marshy_1981 is offline Senior Member
    Join Date
    Feb 2010
    Waterford, Ireland
    Rep Power


    ascii value of 'A'=65(decimal). 65+9=74.

    so say the guess was 'a' which is equal to 97 in decimal. That would leave you
    with 97-65+9=41.
    15+'A' = 15+ 65 = 80;

    80 in ascii = P capital.

    have a look here: Ascii Table - ASCII character codes and html, octal, hex and decimal chart conversion

  3. #3
    alacn's Avatar
    alacn is offline Senior Member
    Join Date
    Jun 2010
    UK. near London
    Rep Power


    tbh looks like very basic encryption
    Teaching myself java so that i can eventually join the industry! Started in June 2010

Similar Threads

  1. Adding Arrays and Enhanced For Loop into program.
    By vinyacam in forum New To Java
    Replies: 1
    Last Post: 05-10-2010, 06:28 AM
  2. What does the letters mean?
    By mustachMan in forum New To Java
    Replies: 3
    Last Post: 02-11-2010, 09:50 PM
  3. Adding two Arrays
    By Mayur in forum New To Java
    Replies: 1
    Last Post: 09-26-2009, 11:49 PM
  4. Adding Values of 2 Arrays
    By core2duo5252 in forum Java 2D
    Replies: 7
    Last Post: 09-05-2009, 03:50 AM
  5. need block letters??
    By dc2acgsr99 in forum New To Java
    Replies: 16
    Last Post: 01-29-2008, 08:31 AM

Posting Permissions

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