Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

ValidatingTrianlges.java

 
Mezan Shareef
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi friends, i am getting errors for this program, saying illegal start of expression, and not a statement. I am unable to figure it out. Please answer me. I would be glad. It is simple but i am unable to do.

QUestion is that, i need to ask user to enter 3 edges of triangle and decide if it is valid triangle or no.
if any two sides of a triangleis greater than third side then it is valid triangle.
else it is not valid. Here is my code.

Thank you.

 
Matthew Brown
Bartender
Posts: 4565
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It's a lot easier for us if you tell us the exact line you're getting the error on. I can see at least one error though - it should be true and false, not True and False.
 
Wouter Oet
Saloon Keeper
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It would help if you told us where the error is coming from and please UseAMeaningfulSubjectLine.

Just count the brackets in your if-statements and you'll find your problem.
 
Matthew Brown
Bartender
Posts: 4565
8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Once you've fixed that, it may well work. But why have you got two complicated conditions? If the first test fails, you know the triangle is invalid. There's no need to test again.
 
fred rosenberger
lowercase baba
Bartender
Posts: 12083
29
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
your parens are not correct on line 14.

The close paren just before the second "&&" matches the first open paren after the "if". The last three close parens don't match anything.
 
Campbell Ritchie
Sheriff
Posts: 48363
56
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
. . . and what about a "triangle" with sides 1, 2 and 3?
 
Mezan Shareef
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you guys, I got it. Fred rossenberger is correct. this program works for 1,2,3. also. The requirement was like that so i had to write it like this i mean, it was an exercise from book. introduction to programming by danial liang, i am learning from this books exercises... true and false were correct only, does not matter small or caps. I needed to put them in inverted commas. that i forgot.

Thank you soo much you all guys, and special thank you to Fred Rossenberger. I would be glad if i can learn good programming. I would be sooooo much thankfull to each single guy who responded to me. Thank you again.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic