Pages

Friday, 19 August 2016

Chapter 5 Exercise 15, Introduction to Java Programming, Tenth Edition Y. Daniel LiangY.

*5.15 (Display the ASCII character table) Write a program that prints the characters in the ASCII character table from ! to ~. Display ten characters per line. The ASCII table is shown in Appendix B. Characters are separated by exactly one space.

public class ProgrammingEx5_15 {
 
 public static void main(String[] args) {
  //From ! to ~ is from 33 to 126 decimal ascii code
   
  for(char i = '!' ; i <= '~'; i++ ){
    
   System.out.print(i + " ");
   if ((i-32)%10 == 0) {
    System.out.println("");
   }
    
  }
 
 }
 
}

No comments :

Post a Comment