Sunday 3 July 2016

Chapter 4 Exercise 8, Introduction to Java Programming, Tenth Edition Y. Daniel LiangY.

*4.8 (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. Here is a sample run:

 Enter an ASCII code: 69
 The character for ASCII code 69 is E 




import java.util.Scanner;
 
public class ProgrammingEx4_8 {
 
 public static void main(String[] args) {
  Scanner input = new Scanner(System.in);
 
  System.out.print("Enter an ASCII code:");
  int s = input.nextInt();
 
  System.out.print("The character for ASCII code " + s + " is "
    + (char) s);
 
 }
 

No comments :

Post a Comment