• Post Reply Bookmark Topic Watch Topic
  • New Topic

Do while loop error  RSS feed

 
kennith stomps
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello, I am receiving the - Syntax error, insert "while ( Expression ) ;" to complete  DoStatement on line 146 when I run the code. Any ideas as to why it may be telling me this when I have a while statement on line 138 ? Thanks much

 
Tim Cooke
Marshal
Posts: 4041
239
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Refresh yourself on the correct format of a do/while loop, and possibly a switch statement, and check your closing parentheses.
 
kennith stomps
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have looked at the correct format and this seems correct, I am not sure what could be wrong
 
Tim Cooke
Marshal
Posts: 4041
239
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Are you sure?
 
kennith stomps
Ranch Hand
Posts: 160
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Yes I am sure, If I haven't I would not be asking the question. I do not understand what is incorrect, or why it would be incorrect
 
Tim Cooke
Marshal
Posts: 4041
239
Clojure IntelliJ IDE Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I was trying to drop a hint that you might not have the correct parenthesis placement for your do/while loop. But you missed it so here it is straight: the parenthesis placement for your do/while loop is wrong.
 
Pete Letkeman
Ranch Foreman
Posts: 902
26
Android Chrome IntelliJ IDE Java MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How closely is this post related to this previous post?
https://coderanch.com/t/684472/java/Input-type-resolved
 
Paul Clapham
Sheriff
Posts: 22827
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The opening { of the do-loop is at line 12. Your while-clause is at line 138, so the } on line 136 should be the closing } of that do-loop. From what you've posted it's extremely difficult to determine whether that is the case or not. If I had to do it I would have to print out the code and mark all of the braces to find out why they didn't match.

Except you told us there's a compiler error, so we know that it isn't the case.

But anyway with over 100 lines of code which is inconsistently indented it's a hard task. Have you learned about methods yet? Hopefully you have, because this is a good place to use one. Take all of that code which is supposed to be inside your do-while loop and put it inside its own method. Then you should have two smaller pieces of code to deal with, which should be a little easier. And fix your code so it's consistently indented, so it would be easier to understand. If you're using an IDE then there's a keystroke for that.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!