• Post Reply Bookmark Topic Watch Topic
  • New Topic

Issue with my loop or something else?  RSS feed

 
Shey Gordon
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.

 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
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.
 
Joe Harry
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!