Outputs a character and its integer equivalent in Java

In this Java program, the application will determine the character values of A, B, C, a, b, c, 0, 1, 2, $, *, +, /,  , to it's integer corresponding values.
This is the same solution of Deitel & Deitel  exercise 2.32 in Chapter 2.
2.32  Write an application that displays the integer equivalents of some uppercase letters, lowercase letters,digits and special symbols.At a minimum, display the integer equivalents of the following A, B, C, a, b, c, 0, 1, 2, $, *, +, /,  and blank character.

import javax.swing.*;

public class CharacterandInteger {

public static void main(String args[]){

//Displays the outputs
JOptionPane.showMessageDialog(null, "The character value of " + 'A' + " has the value of " +
(int) 'A' + "\n" + "The Character value of " + 'B' + " has the value of " +
(int) 'B' + "\n" + "The character value of " +'C' + " has the value of " +
(int) 'C' + "\n" + "The character value of " + 'a' + " has the value of " +
(int) 'a' + "\n" + "The character value of " + 'b' + " has the value of " +
(int) 'b' + "\n" + "The character value of " + 'c' + " has the value of " +
(int) 'c' + "\n" + "The character value of " + '0' + " has the value of " +
(int) '0' + "\n" + "The character value of " + '1' + " has the value of " +
(int) '1' + "\n" + "The character value of " + '2' + " has the value of " +
(int) '2' + "\n" + "The character value of " + '$' + " has the value of " +
(int) '$' + "\n" + "The character value of " + '*' + " has the value of " +
(int) '*' + "\n" + "The character value of " + '+' + " has the value of " +
(int) '+' + "\n" + "The character value of " + '/' + " has the value of " +
(int) '/' + "\n" + "The character value of " + ' ' + " has the value of " +
(int) ' ', "Characters Equivalent to Integer Values", JOptionPane.INFORMATION_MESSAGE);

}
}


Here is the output.

Comments

Popular posts from this blog

Calculate the Sum, Product, Difference & Quotient in Java

Calculates the Squares and Cubes in Java

Determine Two Numbers which is the largest or Both Numbers are Equal in Java