Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 2 of 2

Thread: Take user input

  1. #1
    Junior Member
    Join Date
    Jul 2012
    Location
    Dhaka,Bangladesh
    Posts
    1
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Post Take user input

    I am a newbie in java. I try to solve UVA using java. But there raise a problem of taking input of string and int at a time. Please help me how to do that???
    The inpur is such like...
    "donate 1000"


  2. #2
    Member
    Join Date
    Jun 2012
    Location
    Left Coast, USA
    Posts
    451
    My Mood
    Mellow
    Thanks
    1
    Thanked 97 Times in 88 Posts

    Default Re: Take user input

    Quote Originally Posted by frabbi.cse View Post
    I am a newbie in java...how to do that...
    Here's the thing: There are about a million ways to do stuff like that in Java (maybe more).

    What reference material are you using to learn Java from? Class notes? Textbook? Online tutorials? What?

    If you don't have class notes or a textbook, and/or you can't find examples relevant to your requirements, one place to start might be The "Official" Java tutorial site Slog through the fundamentals (don't skip anything). Eventually you will get to a place where it shows examples reading from user input.


    If you have already covered fundamentals, then consider a plan that does something like:

    1. Create a Scanner object with System.in as the argument. (Reference:The Scanner Class)

    2. Use the Scanner next() method to get user input into a String variable.

    3. Use the Scanner nextInt() method to get user input into an int variable.

    4. Do something interesting with the String and int variables.



    Cheers!

    Z

Similar Threads

  1. User Input with a Do Loop
    By RadiantChaos in forum Loops & Control Statements
    Replies: 4
    Last Post: March 13th, 2012, 07:14 PM
  2. Need help with user input/output for GUI.
    By Tctwins in forum AWT / Java Swing
    Replies: 6
    Last Post: February 20th, 2012, 04:13 PM
  3. Valid user input
    By ChristopherLowe in forum Java Code Snippets and Tutorials
    Replies: 1
    Last Post: June 21st, 2011, 04:53 PM
  4. User Input File Name
    By PineAppleKing in forum Java Theory & Questions
    Replies: 12
    Last Post: June 3rd, 2011, 10:23 AM
  5. User Input Loop
    By cfmonster in forum Loops & Control Statements
    Replies: 7
    Last Post: August 24th, 2009, 01:52 PM

Tags for this Thread