Results 1 to 3 of 3
  1. #1
    jls7168 is offline Member
    Join Date
    Nov 2008
    Posts
    9
    Rep Power
    0

    Exclamation Help making table

    I am trying to make a table of all the ASCII characters but am having some trouble. I have all the characters printed in a list order, but need to make it into about 10 columns across. Any help is really appreciated. Here is my code so far...
    Java Code:
    import corejava.*;
    
    public class Ascii {
    
    	public static void main(String[] args) {
    		
    			System.out.println("\tStandard ASCII Codes");
    			
    			System.out.println("008 - BS");
    			System.out.println("009 - TAB");
    			System.out.println("010 - LF");
    			System.out.println("013 - CR");
    			
    			for (int i = 33; i < 127; i ++){
    				Format.print(System.out, "%03d", i);
    				System.out.println(" - " + (char)i);
    			}
    			System.out.print("127 - DEL");
    			
    			
    			System.out.println("");
    			System.out.println("");
    			
    			String prompt = Console.readString("Press Enter to Continue");
    			System.out.println("");
    			
    			System.out.println("\tExtended ASCII Codes");
    			
    			for (int i = 128; i < 256; i++){
    				System.out.println(i + " - " + (char)i);
    			}
    			
    			
    	}

  2. #2
    angryboy's Avatar
    angryboy is offline Senior Member
    Join Date
    Jan 2009
    Posts
    742
    Rep Power
    6

    Default

    i don't have corejava.* so i can't compile it and test it out.
    but i would use two loops,
    Java Code:
    for (int i = 33; i < 127; i ++){
      loop*(j<11){                             [B]// <-- LOOP + CONDITION[/B]
        Format.print(System.out, "%03d", i);
        System.out.print(" - " + (char)i);     [B]// <-- EDITED[/B]
      }
    }
    Last edited by angryboy; 01-26-2009 at 07:38 AM.
    USE CODE TAGS--> [CODE]...[/CODE]
    Get NotePad++ (free)

  3. #3
    Steve11235's Avatar
    Steve11235 is offline Senior Member
    Join Date
    Dec 2008
    Posts
    1,046
    Rep Power
    7

    Default

    As far as formatting, here are the codes for tab and newline:

    tab = "\t"
    nl = "\n" or "\r\n" (Windows only)

Similar Threads

  1. Need helps making counter
    By Lifeis2evil in forum New To Java
    Replies: 3
    Last Post: 11-27-2008, 12:58 AM
  2. Replies: 2
    Last Post: 07-30-2008, 01:33 PM
  3. Making a stack from a LinkedList
    By Java Tip in forum java.lang
    Replies: 0
    Last Post: 04-16-2008, 11:28 PM
  4. Making triangle
    By banie in forum New To Java
    Replies: 4
    Last Post: 02-02-2008, 12:23 PM
  5. Help with making this algorithm better
    By RLRExtra in forum New To Java
    Replies: 6
    Last Post: 01-17-2008, 05:11 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •