Code doesn't wait for user input?

前端 未结 4 1584
春和景丽
春和景丽 2021-01-22 06:29

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

4条回答
  •  悲&欢浪女
    2021-01-22 06:38

    nextLine eats the newline character. nextInt leaves it in the input buffer, and the next readLine terminates immediately.

    Quick fix: use readLine for everything, then parse the int from string read.

提交回复
热议问题