Results 1 to 5 of 5

Thread: sos

  1. #1
    mosime is offline Member
    Join Date
    Dec 2008
    Posts
    3
    Rep Power
    0

    Default sos

    hi,
    wanna write a code that prints ascii characters from keyboard input,
    plis help,:confused:

  2. #2
    Eranga's Avatar
    Eranga is offline Moderator
    Join Date
    Jul 2007
    Location
    Colombo, Sri Lanka
    Posts
    11,372
    Blog Entries
    1
    Rep Power
    20

    Default

    mosime, this is not a code bank. This is a forum, where we can discuss about anything related with Java. Just helping to there stuff, not doing homework here.

    So you must put some effort first of all. If you stuck on something ask it clear, with what you have tried. Search on the web, you can find lots of similar examples.

  3. #3
    mosime is offline Member
    Join Date
    Dec 2008
    Posts
    3
    Rep Power
    0

    Default

    Quote Originally Posted by Eranga View Post
    mosime, this is not a code bank. This is a forum, where we can discuss about anything related with Java. Just helping to there stuff, not doing homework here.

    So you must put some effort first of all. If you stuck on something ask it clear, with what you have tried. Search on the web, you can find lots of similar examples.
    here is ma code,wanna read characters in ascii,

    System.out.println("Enter a character");
    Char = UserInput.readChar();

    for (i = 0; i<127; ++i;){
    Char = str.charAt(i);
    asciiVal = (int)c;

    }
    System.out.println("ASCII of " + Char + "=" +j+ ".");

  4. #4
    fishtoprecords's Avatar
    fishtoprecords is offline Senior Member
    Join Date
    Jun 2008
    Posts
    571
    Rep Power
    7

    Default

    As a wise person said:
    Use an appropriate Subject. "Help, urgent!" isn't one.

    SOS is not one either.

  5. #5
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    7

    Default hhhmmm...

    The code you have provided is going to nothing as is and I have a sneaking suspition that you don't have a clue what you're doing. I'm assuming you want a program that accepts a letter from the user and shows it's ASCII equivalent. If so...
    • First you need the basics of a standalone program (that contains a main method). To do that, read this:
    Lesson: A Closer Look at the "Hello World!" Application (The Java™ Tutorials > Getting Started)
    • Next you need to understand how the declare variables:

    Variables (The Java™ Tutorials > Learning the Java Language > Language Basics)
    • Next, you need to get the user's input. Unless you have imported the appropiate class, the following code:

    Java Code:
    System.out.println("Enter a character");
    Char = UserInput.readChar();
    ... is no good. The following might help:
    Java Code:
    int userChar;
    Scanner input = new Scanner(System.in);
    System.out.println("Enter a character: ");
    userChar = input.nextInt();
    • Then you need to understand loops, the "for" statement:

    The for Statement (The Java™ Tutorials > Learning the Java Language > Language Basics)
    • Since this as to do with ASCII translations, here's a link to an ASCII table:

    Table of ASCII Characters

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

Posting Permissions

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