This week's book giveaway is in the Cloud/Virtualization forum.
We're giving away four copies of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds and have James Denton on-line!
See this thread for details.
Win a copy of Learning OpenStack Networking: Build a solid foundation in virtual networking technologies for OpenStack-based clouds this week in the Cloud/Virtualization forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Liutauras Vilda
  • Campbell Ritchie
  • Tim Cooke
  • Bear Bibeault
  • Devaka Cooray
Sheriffs:
  • Jeanne Boyarsky
  • Knute Snortum
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Ganesh Patekar
  • Stephan van Hulst
  • Pete Letkeman
  • Carey Brown
Bartenders:
  • Tim Holloway
  • Ron McLeod
  • Vijitha Kumara

Issue with my loop or something else?  RSS feed

 
Greenhorn
Posts: 7
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Forgive me, I have limited experience in Java programming and I'm taking a second course in school right now. The assignment for this week requests a program that allows the user to input occupied hotel room numbers and then search for a room to see if it's occupied or not. This is what I have so far. It compiled fine, but when I try to use it I can only input one number and then it freezes up. By freezing I mean it won't let me enter anything else, nor does it ask the user to enter another number.

 
Java Cowboy
Sheriff
Posts: 16084
88
Android IntelliJ IDE Java Scala Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the ranch.

The problem: Remove the semi-colon at the end of line 12. A second problem: You are using == to compare strings. This doesn't work; you must use equals() instead. So, line 12 should look like this:

The semi-colon you have at the end acts as an empty statement. That means you have a loop with an empty body.
 
Ranch Hand
Posts: 10128
3
Eclipse IDE Mac PPC Ubuntu
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Shey Gordon wrote:Forgive me, I have limited experience in Java programming and I'm taking a second course in school right now. The assignment for this week requests a program that allows the user to input occupied hotel room numbers and then search for a room to see if it's occupied or not. This is what I have so far. It compiled fine, but when I try to use it I can only input one number and then it freezes up. By freezing I mean it won't let me enter anything else, nor does it ask the user to enter another number.



Welcome to the ranch! You will learn a lot through Coderanch. Have fun programming!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!