Posted by: khai_k_khai_k November 9, 2008
Java prog help!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
Login in to Rate this Post:     0       ?        
More elegant way to do the above program, in which you just have to change a variable for displaying the number of columns: public class AsciiPrinter { public static void main(String[] args) { int numberOfColumns = 5; for (int i = 32; i <= 126; i += numberOfColumns) { int columnPointer = 0; while (columnPointer < numberOfColumns) { System.out.print( (i + columnPointer) + ": " + (char) (i + columnPointer) + " \t"); columnPointer++; } System.out.println(); } } }
Read Full Discussion Thread for this article