Question: i have stuck on this part Part B . Add the following methods to the Triangle class: public boolean isEquilateral returns true if the triangle
Part B . Add the following methods to the Triangle class: public boolean isEquilateral returns true if the triangle is an equilateral triangle, false otherwise. public boolean isRight() - returns true if the triangle is a right-angle triangle, false otherwise. (Hint: Can use the Pythagorean Formula). Consult math texts or online sources if you forget the definitions of "equilateral" or "right-angle", or if you can't recall a formula. IMPORTANT NOTE regarding equality comparisons!: When working with floating- point numbers in Java (or any programming language), calculations don't work out exactly as we might expect. For instance, we may perform some calculations and end up with an answer like: 3.999999... instead of the expected answer of 4. This happens because of the limited precision used to store/represent floating- point numbers in a computer. Therefore, rather than comparing two double values using: if (numl == num2) {... you should instead calculate the difference between the two numbers and then compare that to some really, really small value. If the difference is less than that really small value, then the two numbers are, essentially, equal. For example, use: if (Math.abs (numl-num2)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
