Characters are Numbers
Completed
Read a lowercase letter. Print its Unicode code, the next letter, and the letter in upper case.
Input
One lowercase letter (not z).
Output
Three lines.
Example
Input
a
Output
97 b A
Editor
Java
Hints
A char is stored as a number; (int) c shows it.
c + 1 is an int, so cast it back to char.
Solution explanation
Characters can take part in arithmetic, which is handy for ciphers and counting letters.
Show solution
import java.util.Scanner;
public class Main {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
char c = sc.next().charAt(0);
System.out.println((int) c);
System.out.println((char) (c + 1));
System.out.println(Character.toUpperCase(c));
}
}