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 5 of 5

Thread: User Input (Press Enter)

  1. #1
    Junior Member iCurtisIT's Avatar
    Join Date
    Oct 2013
    Location
    UK
    Posts
    22
    My Mood
    Confused
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default User Input (Press Enter)

    Hey!

    I don't know if this query is in the correct place. If it isn't, sorry, and could someone please move it.

    I am making a Volume calculator as my first piece of coursework and I need the user to input their measurements. I have done this using the following code:

    // This will ask the user to input the length
    System.out.println("Please enter the length: (in centimetres)");
    length = console.nextInt();

    What I am wandering is, How do I make it so before this bit comes up, I can say something like "Welcome to my Volume Calculator, Press Enter to continue"?

    (This is not needed for my coursework, I just wanna make it look a little nicer/professional.

    Thank you for reading and your help.

    Curtis.


  2. #2
    Forum Squatter newbie's Avatar
    Join Date
    Nov 2010
    Location
    North Wales
    Posts
    661
    My Mood
    Stressed
    Thanks
    28
    Thanked 115 Times in 106 Posts
    Blog Entries
    1

    Default Re: User Input (Press Enter)

    		System.out.println("Press enter to continue.");
    		console.nextLine();

    As simple as that; tell me if i've missed the point.
    Please use [highlight=Java]//code goes here...[/highlight] tags when posting your code

  3. The Following User Says Thank You to newbie For This Useful Post:

    iCurtisIT (October 9th, 2013)

  4. #3
    Crazy Cat Lady KevinWorkman's Avatar
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    5,424
    My Mood
    Hungover
    Thanks
    144
    Thanked 636 Times in 540 Posts

    Default Re: User Input (Press Enter)

    You can read the next line without actually doing anything with the value.

    Edit: I'm too slow!
    Useful links: How to Ask Questions the Smart Way | Use Code Tags | Java Tutorials
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

  5. #4
    Junior Member iCurtisIT's Avatar
    Join Date
    Oct 2013
    Location
    UK
    Posts
    22
    My Mood
    Confused
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Re: User Input (Press Enter)

    Thank you very much. I just tried something similiar but I kept on getting errors. I am new to this so, so may ask a few more very basic questions, hehe.

    Thanks again. Appreciate it.

  6. #5
    Grand Poobah
    Join Date
    Mar 2011
    Posts
    1,545
    My Mood
    Grumpy
    Thanks
    0
    Thanked 167 Times in 158 Posts

    Default Re: User Input (Press Enter)

    We don't read minds. If you get errors then post the exact message here. As well as your code or if it is too long a SSCCE.
    Improving the world one idiot at a time!

Similar Threads

  1. Have user enter in 2 inputs instead of using -1 to end. Help appreciated!
    By neontiger in forum What's Wrong With My Code?
    Replies: 3
    Last Post: February 21st, 2012, 04:26 AM
  2. Replies: 5
    Last Post: August 11th, 2011, 12:39 PM
  3. i dont know why i cant see the output nor enter input
    By Newbiesss in forum What's Wrong With My Code?
    Replies: 2
    Last Post: June 1st, 2011, 12:41 PM
  4. command prompt, acquiring input without enter?
    By kitube in forum File I/O & Other I/O Streams
    Replies: 0
    Last Post: January 24th, 2011, 10:14 PM
  5. How to make user press enter to continue in program?
    By BC2210 in forum File I/O & Other I/O Streams
    Replies: 3
    Last Post: October 3rd, 2009, 05:08 AM

Tags for this Thread