The following code is to convert the ASCII Code to its character form.
Code:-
import java.util.*;
public class CharacterASCII{
Scanner scan=new Scanner(System.in);
int asc;
char character;
String ascii;
public void input(){
try{
System.out.println("Enter any ASCII Code to print the character of the code: ");
asc=scan.nextInt();
}
catch(NumberFormatException e){
System.out.println("Error Code: "+e);
System.exit(0);
}
}
public void compute(){
ascii=new Character((char)asc).toString( );
System.out.println("Character at ASCII Code \""+asc+"\" is \""+ascii+"\"");
}
public static void main(String[] args){
CharacterASCII asci=new CharacterASCII();
asci.input();
asci.compute();
}
}
Output:-
Enter any ASCII Code to print the character of the code:
65
Character at ASCII Code "65" is "A"
Code:-
import java.util.*;
public class CharacterASCII{
Scanner scan=new Scanner(System.in);
int asc;
char character;
String ascii;
public void input(){
try{
System.out.println("Enter any ASCII Code to print the character of the code: ");
asc=scan.nextInt();
}
catch(NumberFormatException e){
System.out.println("Error Code: "+e);
System.exit(0);
}
}
public void compute(){
ascii=new Character((char)asc).toString( );
System.out.println("Character at ASCII Code \""+asc+"\" is \""+ascii+"\"");
}
public static void main(String[] args){
CharacterASCII asci=new CharacterASCII();
asci.input();
asci.compute();
}
}
Output:-
Enter any ASCII Code to print the character of the code:
65
Character at ASCII Code "65" is "A"
Comments