Results 1 to 5 of 5

Thread: ASCII Table

Threaded View

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Feb 2002
    Posts
    159

    Question ASCII Table

    i am experamenting with JAVA.

    I wanna write a program which will print an ASCII values table using a for loop.

    So if i type in a Start Value of "A" and a Last Value of "}" the output should be

    ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_`abcdefghijklmnopqrstuvwxyz{|}

    Error conditions
    ================
    If the last character is before the start character print an error message saying:

    "Error - last is before start"

    Here is the code i have writen so far.. but i cant get the output to show can any one tell me where i am going wrong.

    Code:
    public class Ascii {
    
    
        public static void main(String[] argv) {
    
        char startChar, lastChar;
        String ascii = "";
        
        System.out.println ("Please type the start character");
        startChar = UserInput.readChar();
        
        System.out.println ("Please type the last character");
        lastChar = UserInput.readChar();
        
        if (lastChar < startChar){
            System.out.println ("Error, last character is before start character");
        }
        
        for (startChar = startChar; startChar == lastChar; ++startChar){
            
        }
    
        ascii = ascii + startChar;
    
        System.out.println (ascii);
        } // end of main
        
    } // end class
    thanx ppl
    Last edited by NOTSOSURE; Dec 7th, 2002 at 05:00 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
  •  



Click Here to Expand Forum to Full Width