Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8054115
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T08:04:36+00:00 2026-06-05T08:04:36+00:00

I have to do a project for my Computer Science class. The problem is:

  • 0

I have to do a project for my Computer Science class. The problem is:

Patrons of a library can borrow up to three books. A patron, therefore, has a name and up to three books. A book has an author and a title. Design and implement two classes, Patron and Book, to represent these objects and the following behavior:

  • The client can instantiate a book with a title and author
  • The client can examine but not modify a book’s title or author
  • The client can ask a patron wthere it has borrowed a given book (identified by title).
  • The client can tell a patron to return a given book (identified by title).
  • The client can tell a patron to borrow a given book.

The Patron class should use a seperate instance variable for each book (a total of three).
Each of these variables is initially null. When a book is borrowed, the patron looks for a variable that is not null. If no such variable is found, the method returns false. If a null variable is found, it is reset to the new book and the method returns true. Similar considerations apply to other methods. Use the method aString.equals(aString) to compare two strings for equality. Be sure to include appropriate toString methods for your classes and test them with a tester program.

Here is my Client class, which contains the main method: http://pastebin.com/JpxCT2F6

Now my problem is that when I run the program, the program doesn’t wait for user input. Here is what comes up in the console of Eclipse:

Please enter title of book 1: 
s
Please enter author of book 1: 
e
Please enter title of book 2: 
f
Please enter author of book 2:
t
Please enter title of book 3: 
g
Please enter author of book 3:
d
Which book would you like to check for?
s
The patron has taken out the book s
Would you like to return a book? (1 yes or 2 no)
1
Which book would you like to return?
Sorry, could not find the book 
Would you like to take out a book? (1 yes or 2 no)
2
Invalid option
Which book would you like to check for?
The patron does not have  taken out
Would you like to return a book? (1 yes or 2 no)

Ass you can see, the console doesn’t wait for user input after “Which book would you like return?” Instead, it takes a blank value. And later in the code, i put in “2”, which means to return no book, but instead gives me an invalid input output.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T08:04:37+00:00Added an answer on June 5, 2026 at 8:04 am

    You use nextInt() on line 71 of your code, which gets the integer answer the user provides. Then you use nextLine() which Advances this scanner past the current line and returns the input that was skipped.. The input that is skipped is only the newline character from the previous nextInt() call (It doesn’t read the whole line only the int).

    You can skip this by calling input.nextLine() once before you want the input, or by using nextLine() instead of nextInt() and converting the string to the integer value.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an project with many Books. Each book has many Pages. I would
I am working on a project for my computer security class and I have
I am college student (computer science) and have just started a C# programming class.
I'm working on a project for my computer science class that basically uses an
I am currently working on a computer science project where I have to evaluate
I have three computer in a office and I have installed my C#-2005 Project
I have inherited a project that logs data from a single board computer to
I have a project with Spring, JSF and Hibernate. This project has been developed
I have a project on one computer that I need to work on another
I have a project which has been checked out of Subversion and uses Scons

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.