PROGRAM TO PRINT THE ASCII CODES OF LETTERS
ASCII stands for AMERICAN STANDARD CODE FOR INFORMATION INTERCHANGE.
It returns the integer values of the characters specified
A to Z The ASCII code is from 65 - 90
a to z The ASCII code is from 97 - 122
0 to 9 The ASCII code is from 48 - 57
Space character (' ' ) The ASCII code is 32.
The following program segment shows how to print the ASCII values of capital letters and small letters.
import java.util.*;
class ASCII
{
public static void main (String args[])
{
Scanner ob = new Scanner (System.in);
System.out.println("Press 1 for unicode of capital letters");
System.out.println("Press 2 for unicode of small letters");
System.out.println("enter your choice");
int choice = ob.nextInt();
switch(choice)
{
case 1 :
char ch;
System.out.println("LETTERS \t UNICODE");
for(ch = 'A' ; ch <= 'Z' ; ch++)
{
System.out.println(ch +"\t" + (int)ch);
}break;
case 2:
char cs;
for(cs = 'a' ; cs <= 'z'; cs++)
{
System.out.println(cs+ "\t"+(int)cs);
}
break;
default :
System.out.println("wrong choice entered");
}
}
}
Comments
Post a Comment