Problem

Write the method called printTriangleType referred to in Self-Check Problem. This method a...

Write the method called printTriangleType referred to in Self-Check Problem. This method accepts three integer arguments representing the lengths of the sides of a triangle and prints the type of triangle that these sides form. Here are some sample calls to printTriangleType:

printTriangleType (5, 7, 7);printTriangleType (6, 6, 6);printTriangleType (5, 7, 8);printTriangleType (2, 18, 2);

The output produced by these calls should be

isoscelesequilateralscaleneisosceles

Your method should throw an IllegalArgumentException if passed invalid values, such as ones where one side’s length is longer than the sum of the other two, which is impossible in a triangle. For example, the call of printTriangleType (2, 18, 2); should throw an exception.

Problem

Consider a method printTriangleType that accepts three integer arguments representing the lengths of the sides of a triangle and prints the type of triangle that these sides form. The three types are equilateral, isosceles, and scalene. An equilateral triangle has three sides of the same length, an isosceles triangle has two sides that are the same length, and a scalene triangle has three sides of different lengths.

However, certain integer values (or combinations of values) would be illegal and could not represent the sides of an actual triangle. What are these values? How would you describe the precondition(s) of the printTriangleType method?

Step-by-Step Solution

Request Professional Solution

Request Solution!

We need at least 10 more requests to produce the solution.

0 / 10 have requested this problem solution

The more requests, the faster the answer.

Request! (Login Required)


All students who have requested the solution will be notified once they are available.
Add your Solution
Textbook Solutions and Answers Search
Solutions For Problems in Chapter 4
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT