wood burning stoves 2.0*
The moose likes Beginning Java and the fly likes ValidatingTrianlges.java Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "ValidatingTrianlges.java" Watch "ValidatingTrianlges.java" New topic


Mezan Shareef
Ranch Hand

Joined: Apr 01, 2010
Posts: 40
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

Joined: Apr 06, 2010
Posts: 4343

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

Joined: Oct 25, 2008
Posts: 2700

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.

"Any fool can write code that a computer can understand. Good programmers write code that humans can understand." --- Martin Fowler
Please correct my English.
Matthew Brown

Joined: Apr 06, 2010
Posts: 4343

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

Joined: Oct 02, 2003
Posts: 11155

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.

There are only two hard things in computer science: cache invalidation, naming things, and off-by-one errors
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 38001
. . . and what about a "triangle" with sides 1, 2 and 3?
Mezan Shareef
Ranch Hand

Joined: Apr 01, 2010
Posts: 40
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.
I agree. Here's the link: http://aspose.com/file-tools
subject: ValidatingTrianlges.java
Similar Threads
if statement problem
Certificates and Key tutorial
override the equals and hashcode
(new to java)variables might not have been initialized
print a HashSet of objects