Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Define a Triangle class with three private double instance variables, each of which represents the length of one side of the triangle, and a single

image text in transcribed

Define a Triangle class with three private double instance variables, each of which represents the length of one side of the triangle, and a single three-argument constructor. For any triangle, the sum of any two sides must be greater than the remaining side. Your Triangle class must adhere to this rule. 2. Define an IllegalTriangleException class (an empty subclass of Exception), and define Triangle's constructor to raise an IllegalTriangleException if the user attempts to create a Triangle whose sides violate the rule above. Your Triangle constructor header should resemble the following: /**Construct a triangle with the specified sides */ public Triangle (double sidel, double side2, double side3) throws IllegalTriangleException // Implement your constructor Finally, define a main() method (inside Triangle or in a separate diver class) that prompts the user to enter a length for each side, and then creates a new Triangle with those values. If the user enters an invalid set of values (meaning that the Stony Brook University CSE 114: Computer Science I Fall 2017 Triangle constructor generates an exception), your program should use exception- haning to prit an appropriate messag instead of simply crashing

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Marketing Database Analytics

Authors: Andrew D. Banasiewicz

1st Edition

0415657881, 978-0415657884

More Books

Students also viewed these Databases questions

Question

Using Language That Works

Answered: 1 week ago