Hint: Manipulating a character

It may seem a little strange, but type char in Java is actually a kind of integer. That means that you can do arithmetic on characters.

The one catch that you need to be aware of is that type char is smaller than type int, which means that when you mix a char and an int in arithmetic, the result will be an int.

For this assignment, we do get to assume that we are dealing with the English alphabet (very considerate of those Romans and Gauls, if you ask me) as represented in ASCII. That means that we know that the uppercase letters are numerically consecutive, running from 'A' to 'Z', and that the lowercase letters are numerically consecutive, from 'a' to 'z'.


Cary Gray
Last modified: Fri Sep 9 11:53:48 CDT 2011