The program below is the answer to Deitel’s Java How to Program (9th Edition) Chapter 2 Exercise 2.29.
		
		
			
			
			
			
				
					
			
		
		
			
			
			
			
				
					
			
		
				
		Question: Write an application that displays the integer equivalents of some uppercase letters, lowercase letters, digits and special symbols. Display the integer equivalents of the following: A B C a b c 0 1 2 $ * + / and the blank character.
| 1 2 | /**<br /> *<br /> * @Author: Aghatise Osazuwa<br /> * Website: www.cscprogrammingtutorials.com<br /> *<br /> * Exercise 2.29 - Integer Value Of A Character<br /> * This Program Displays The Integer Equivalents Of Some Uppercase Letters, <br /> * Lowercase Letters, Digits And Special Symbols<br /> *<br /> */ <br /><br /><br />public class Ex02_29 {<br />    public static void main (String [] args) {<br /><br />       System.out.printf("The character %c has the value %dn", 'A', ((int) 'A' ));<br />       System.out.printf("The character %c has the value %dn", 'B', ((int) 'B' ));<br />       System.out.printf("The character %c has the value %dn", 'C', ((int) 'C' ));<br />       System.out.printf("The character %c has the value %dn", 'a', ((int) 'a' ));<br />       System.out.printf("The character %c has the value %dn", 'b', ((int) 'b' ));<br />       System.out.printf("The character %c has the value %dn", 'c', ((int) 'c' ));<br />       System.out.printf("The character %c has the value %dn", '0', ((int) '0' ));<br />       System.out.printf("The character %c has the value %dn", '1', ((int) '1' ));<br />       System.out.printf("The character %c has the value %dn", '2', ((int) '2' ));<br />       System.out.printf("The character %c has the value %dn", '$', ((int) '$' ));<br />       System.out.printf("The character %c has the value %dn", '*', ((int) '*' ));<br />       System.out.printf("The character %c has the value %dn", '+', ((int) '+' ));<br />       System.out.printf("The character %c has the value %dn", '/', ((int) '/' ));<br />       System.out.printf("The Blank character (' ') has the value %dn", ( (int) ' ' )));<br /><br />    }<br />}<br /> | 
The program below is a modified version of the above such that the user can enter a character and the program displays its integer equivalent.
| 1 2 | import java.util.Scanner;<br /><br />public class Modified_Ex02_29 {<br />    public static void main (String [] args) {<br /><br />        Scanner input = new Scanner (System.in);<br /><br />        System.out.print("Enter a character: " );<br />        char character = input.next().charAt(0); //read only the first character entered<br />        System.out.printf("The character %c has the value %dn", character, ((int) character ));<br /><br />    }<br />}<br /> | 
 
				
		 
			
1 Comment
Hi,
Integer equivalent of characters is explained with example programs. Thanks for posting.
http://kosmiktechnologies.com/java-training-institutes-in-kukatpally/