P maps to 15 Note that P is the 15th letter after A A maps to 0 P has ASCII value 80 N maps to 13 A has ASCII value 65 T maps to 19 H maps to 7 redAmount = 10 * ( (int) input.charAt(i) - 65 ); E maps to 4 R maps to 17 Color colorForRect = new Color( redAmount, 0, 255 ); S maps to 18 Letter A would have redAmount of 0, B would have 10, C would have redAmount of 20, ... Z would have 250 input = input.toUpperCase(); for (int i = 0; i < input.length(); i++) { int charValue = (int) input.charAt(i) - 65; System.out.println( input.charAt(i) + " maps to " + charValue ); }