• Source
    1. /* package whatever; // don't place package name! */
    2.  
    3. /* Name of the class has to be "Main" only if the class is public. */
    4. class Ideone
    5. {
    6. static char decrypt(char c, int k)
    7. {
    8. return (char)(((int)(c-'A')+26-k)%26+'a');
    9. }
    10. public static void main (String[] args) throws java.lang.Exception
    11. {
    12. String cipher="AJY";
    13. char cipherAlphabet[]=cipher.toCharArray();
    14. for(int k=1; k<26; k++)
    15. {
    16. System.out.print(k+"--->");
    17. for(int i=0; i<cipherAlphabet.length; i++)
    18. {
    19. System.out.print(decrypt(cipherAlphabet[i],k));
    20. }
    21. System.out.println();
    22. }
    23.  
    24. }
    25. }