Solution:
import java.io.*;
class CharToAscii
{
public static void main(String abc[])
{
System.out.println("Enter a character");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
try{
int c=br.read();
System.out.println("The ascii value of above character is " + c);
}
catch(Exception e)
{
System.out.println("Error...");
}
}}
Output:
C:\> java CharToAscii
Enter a character
A
The ascii value of above character is 65
import java.io.*;
class CharToAscii
{
public static void main(String abc[])
{
System.out.println("Enter a character");
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
try{
int c=br.read();
System.out.println("The ascii value of above character is " + c);
}
catch(Exception e)
{
System.out.println("Error...");
}
}}
Output:
C:\> java CharToAscii
Enter a character
A
The ascii value of above character is 65