Triangle Hint

This problem is much trickier than it looks. There are two main problems

  1. Some of the tests are tricky enough. For example, if any two sides of a triangle are equal, then the triangle is isosceles. How do you test for that.
  2. You need to consider carefully the order of the tests. For example, does it make sense to check that the triangle is impossible after you check that it is isosceles.

So how do you do it. As usual, plenty of thinking and plenty of paper. Write down all the different types of classification and write down values of a, b and c which correspond to each classification. Find boolean tests that can distinguish the different types of triangle.

Then think about how to arrange these if statements. Remember that the order is important. For example, there is no point testing that a triangle is impossible after you have already established that it is equilateral.