My solution keeps coming up as true and i cannot make it say false if it is not true. The question is to write a program that validates a triangle. Any two integers added together must be larger than the last number to be a triangle.

Why are you using one input and the % operator? What happens if your triangle has sides 10, 11 and 12? Why not use three inputs to the three sides?

If you are having problems with Exceptions with Scanner try entering all three numbers in one line

10 11 12

instead of

10
11
12

. . . and ask again because there is a pitfall with Scanner which you may not be aware of.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38363

23

posted

0

You are also testing wrongly. You want to test that a + b > c (don't use capitals or upper-case for variables) AND b + c > a AND a + c > b all together. Your application tests for them individually, and one of them will always turn out to be true.

Nick Hallloran
Greenhorn

Joined: Feb 09, 2010
Posts: 19

posted

0

I did a little revising and it finally is starting to show false statements that are false and true statements that are true. Thank you for all of your responses. There is just one more thing, How do i enable the user to be able to input three numbers on the same line with spaces in between the numbers?

BTW In the question that I am doing in my textbook asks for all of the numbers on one line, not up and down or individually.

Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 38363

23

posted

0

You get something looking like this:

Please enter the three numbers: 3 4 5
Bingo! A real triangle

If you have problems if you enter the three numbers on separate lines, ask again. And I shan't answer because I am going away for the weekend.