Find the character of an ASCII code Write a program that rec

(Find the character of an ASCII code) Write a program that receives an ASCII code (an integer between 0 and 127) and displays its character. For example, if the user enters 97, the program displays the character a. Here is a sample run:

Solution


Solution:

public static void main(String[] args) {
Scanner s = new Scanner(System.in);
int ch;

System.out.print(\"Enter an ASCII code:\");
ch = s.nextInt();

if(ch < 0 || ch > 127) {
System.out.print(\"Invalid data. Number must be between 0 and 127.\");
} else {
System.out.print(\"The character for ASCII code \" + ch + \" is \" + (char)ch);
}
}

 (Find the character of an ASCII code) Write a program that receives an ASCII code (an integer between 0 and 127) and displays its character. For example, if th

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site