English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

1 answers

// Map for lowercase characters.
// 'a' becomes the first character
// in the map, 'b' the second, etc.
final String lowercaseMap = "1234567890abcdefghijklmnop";
// Map for uppercase characters.
// 'A' becomes the first character
// in the map, 'B' the second, etc.
final String uppercaseMap = "ZXYWVUTSABCDEFGHIJKLMNOPQR";

public static void main(String[] args) {
for (int i=0; i for (int j=0; j char c = args[i].charAt(j);
if ((c >= 'a') && (c <= 'z'))
System.out.print( (char) lowercaseMap.charAt(c - 'a'));
else if ((c >= 'A') && (c <= 'Z'))
System.out.print( (char) uppercaseMap.charAt(c - 'A'));
else System.out.print( (char) c );
}
System.out.println();
} }

=====================
Sample execution:

java TestClass abcdef ABCDEF

Sample output:
123456
ZXYWVU

2007-07-11 12:48:28 · answer #1 · answered by McFate 7 · 0 0

fedest.com, questions and answers