Scanner help

Discussion in 'Java' started by ZKR, May 11, 2012.

  1. ZKR

    ZKR

    Joined:
    May 11, 2012
    Messages:
    1
    Hey guys, need some scanner help.

    Code:
    System.out.print ("Title: ");
    				title = scan.nextLine();
    				System.out.print ("Author: ");
    				author = scan.nextLine();
    				System.out.print ("Pages: ");
    				pages = scan.nextInt();
    				myLibrary.addBook (title, author, pages);
    
    When I run it, won`t let me enter title:

    (Run screen) :

    What would you like to do (A=add, B=borrow, C=copy, L=largest check, P=Print libraryQ=quit)? a
    Title: Author: Didn`t let me enter the title !


    If I change the scan.nextLine(); to scan.next(); it will let me enter but only one token (no more than two words).

    Appreciate any help.
    ZKR, May 11, 2012
    #1
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?V29uZw==?=

    Asp.net upload file links to virus scanner

    =?Utf-8?B?V29uZw==?=, Aug 30, 2004, in forum: ASP .Net
    Replies:
    0
    Views:
    505
    =?Utf-8?B?V29uZw==?=
    Aug 30, 2004
  2. =?Utf-8?B?V29uZw==?=

    Asp.net Upload File links to Virus Scanner

    =?Utf-8?B?V29uZw==?=, Aug 30, 2004, in forum: ASP .Net
    Replies:
    4
    Views:
    3,973
    bsandhu
    Dec 16, 2005
  3. teddysnips@hotmail.com

    Suppress keyboard, allow barcode scanner

    teddysnips@hotmail.com, Oct 13, 2005, in forum: ASP .Net
    Replies:
    5
    Views:
    1,585
    tehka
    Sep 5, 2006
  4. benjamin.grant@duke.edu

    python readline error - please help - need it for scanner!

    benjamin.grant@duke.edu, Sep 9, 2006, in forum: Python
    Replies:
    0
    Views:
    295
    benjamin.grant@duke.edu
    Sep 9, 2006
  5. Frederic Wenzel
    Replies:
    0
    Views:
    382
    Frederic Wenzel
    Sep 9, 2006
Loading...

Share This Page