Results 1 to 4 of 4
  1. #1
    waao is offline Member
    Join Date
    Aug 2011
    Posts
    7
    Rep Power
    0

    Default How to "'Read" what has been typed in an to be able to know

    Ok so i want to create this quiz in the cmd but i am stuck :(

    What i want to do is so the person answers the question with an "N" for no and a "Y" for yes..
    I know how i can "Read" the character then out print it but i dont know how i can get the value my slef..

    I want to do somthing liek this:

    Java Code:
    char n;
          n = (char)System.in.read();
          System.in.read();
    if(n == "N") {
    //My code to do if they typed in N (No)
    }else{
    //My code if they typed in Y (Yes)
    }

  2. #2
    waao is offline Member
    Join Date
    Aug 2011
    Posts
    7
    Rep Power
    0

    Default Re: How to "'Read" what has been typed in an to be able to know

    Is this possible?

  3. #3
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    4,016
    Rep Power
    10

    Default Re: How to "'Read" what has been typed in an to be able to know

    Don't bump your thread like that- not only does it make you look impatient, but it also makes it look like you're already receiving replies. Bumping a thread actually decreases your chances of getting help.

    You're mixing chars and Strings. Chars use ' ' and Strings use " ".

    Also, don't use == with Strings. Use .equals().
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  4. #4
    waao is offline Member
    Join Date
    Aug 2011
    Posts
    7
    Rep Power
    0

    Default Re: How to "'Read" what has been typed in an to be able to know

    Oh ok, and sorry will note that for future..

Similar Threads

  1. Replies: 8
    Last Post: 11-05-2010, 12:03 AM
  2. Replies: 1
    Last Post: 01-21-2010, 10:20 AM
  3. Replies: 2
    Last Post: 01-24-2009, 07:56 PM
  4. Can't get my "if" statement to read user input
    By daletron3030 in forum New To Java
    Replies: 7
    Last Post: 01-16-2009, 06:24 AM
  5. Replies: 1
    Last Post: 10-20-2008, 08:35 AM

Posting Permissions

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