• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

ValidatingTrianlges.java

 
Ranch Hand
Posts: 40
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.

 
Bartender
Posts: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Bartender
Posts: 2700
IntelliJ IDE Opera
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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: 4568
9
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
lowercase baba
Posts: 13089
67
Chrome Java Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
Marshal
Posts: 79178
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • 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
    Number of slices to send:
    Optional 'thank-you' note:
  • 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.
 
reply
    Bookmark Topic Watch Topic
  • New Topic