public class ROT13 { static String getROT13String(String s) { char buf[] = s.toCharArray(); for (int i = 0; i < buf.length; ++i) buf[i] = rotateChar(buf[i]); return new String(buf); } static char rotateChar(char c) { if ((c >= 'A') && (c <= 'Z')) c = (char)((c - 'A' + 13) % 26 + 'A'); else if ((c >= 'a') && (c <= 'z')) c = (char)((c - 'a' + 13) % 26 + 'a'); else if ((c >= '0') && (c <= '9')) c = (char)((c - '0' + 5) % 10 + '0'); return c; } public static void main(String args[]){ String s = getROT13String(args[0]); System.out.println(s); System.out.println(getROT13String(s)); } }