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

    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
    Location
    Waterford, Ireland
    Posts
    748
    Rep Power
    5

    Default

    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.
    41%26=15;
    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
    Location
    UK. near London
    Posts
    118
    Rep Power
    0

    Default

    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, 07:28 AM
  2. What does the letters mean?
    By mustachMan in forum New To Java
    Replies: 3
    Last Post: 02-11-2010, 10:50 PM
  3. Adding two Arrays
    By Mayur in forum New To Java
    Replies: 1
    Last Post: 09-27-2009, 12:49 AM
  4. Adding Values of 2 Arrays
    By core2duo5252 in forum Java 2D
    Replies: 7
    Last Post: 09-05-2009, 04:50 AM
  5. need block letters??
    By dc2acgsr99 in forum New To Java
    Replies: 16
    Last Post: 01-29-2008, 09: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
  •