+1 714-215-3097

(Solved) : Write C Console Application Defines Triangle Class Throws Instance Class Named Invalidtria Q35544578

Write a C++ console application that defines a Triangle classthat throws an instance of a class namedInvalidTriangleException.

The triangle class should include 3 private data members for the3 sides of the triangle and public methods that return the area andperimeter. The constructor should validate the 3 side lengths thatit receives as parameters in order to initialize a valid triangle.Any 2 sides added together should be greater than the 3rd side(recall the Heron’s formula assignment). The constructor shouldthrow an instance of the InvalidTriangleException class if the sidelengths are invalid.

Create a class named InvalidTriangleException that inherits fromthe exception class and overrides the what( ) method.

From main, prompt the user for the 3 sides of a triangle andthen try to construct a triangle object. Catch anyexceptions and print any exception messages. If the triangle objectis successfully constructed, then print it’s area and perimeter ina pleasing format. Use a loop to allow the user to repeatedlycreate triangles for testing purposes.

Leave a Reply

Your email address will not be published. Required fields are marked *