• Post Reply Bookmark Topic Watch Topic
  • New Topic

while loop not working  RSS feed

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So the while loop is not working, even though it compiles.  How do I position it??




 
Ranch Hand
Posts: 448
3
Android Eclipse IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What are you trying to achieve ?
 
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
In line 43 of class StudentDriver, you set the variable prompt to the value "Y" (upper-case letter Y).

In line 44, you have a while loop that will run as long as the variable prompt has the value "y" (lower-case letter Y).

Since you've just set prompt to "Y", which is not equal to "y", the loop doesn't run at all.
 
Ranch Hand
Posts: 131
1
Java Oracle
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jesper de Jong wrote:In line 43 of class StudentDriver, you set the variable prompt to the value "Y" (upper-case letter Y).

In line 44, you have a while loop that will run as long as the variable prompt has the value "y" (lower-case letter Y).

Since you've just set prompt to "Y", which is not equal to "y", the loop doesn't run at all.


I agree with that , you should use equalsIgnoreCase()
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!