Question: Write in JAVA Modified the Triangle class you created for lab # 2 . In a triangle, the sum of any two sides is greater
Write in JAVA
Modified the Triangle class you created for lab # In a triangle, the sum of any two sides is greater than the other side.
Define the IllegalTriangleException class that extends the Exception class. This class contains only two constructors: a noarg constructor and a constructor which takes a string parameter.
Modify the second constructor of the Triangle class The constructor creates a triangle with the specified side side and side In this constructor, if the three sides violate the rule specified above, throw an IllegalTriangleException exception.
Write a test program that does the following tasks:
Create a text file called sides.txt which contains three randomly generated integers between and
Input the three integers from the sides.txt file.
Write a try block. In the block, create a new Triangle object using the three integers.
Write a catch block to handle the IllegalTriangleException. In the block, print the message: "IllegalTriangleException: The triangle cannot be created."
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
