Please write in C++. Thank you in advance. Requested files: GeometricArea.cpp,…

Please write in C++. Thank you in advance.

Requested files: GeometricArea.cpp, SpecificationException.h, SpecificationException_test.cpp
Maximum number of files: 4

Extend the GeometricArea.cpp program you wrote to use an exception to handle user input where the parameters entered do not meet specifications, or that simply don’t make sense. In the case of GeometricArea this occurs when the number of sides is two (2).

You should create a class SpecificationException that is thrown whenever your program encounters a specification that does not make sense. For example, if your program is asked to compute the area of a 2 sided polygon, You should throw a SpecificationException, because the fewest number of sides a polygon can have is 3..

You can create this class using only an interface (or header) file called SpecificationException.h. Simply include this header file in your GeometricArea.cpp source code and you can use that exception object..

The test driver for this program is named SpecificationException_test.cpp because it is supposed to call GeometricArea functions with values that trigger an exception.

This is my code for GeometricArea.cpp

GeometricArea.h

6 7 #ifndef GEOMETRICAREA_H 8 #define GEOMETRICAREA_H 9 #include 10 11class Circle 12 { 13private: 14double side; 15 16public: 17 //Exception for negative 18class NegativeSize 19 { }; 20 21 //Default constructor 22 Circle() 23 {side = 0.0;} 24 25 //Mutator functions 26void setSide (double); 27 28 //Accessor functions 29double getSide()const 30 {return side;} 31 32double getArea()const 33 {return (3.14)*(pow(side, 2.0));} 34 }; 35class Triangle 36 { 37private: 38float side1; 39float side2; 40float side3; 41 42public: 43 //Exception for negative 44class NegativeSide1 45 { }; 46 47class NegativeSide2 48 { }; 49 50class NegativeSide3 51 { }; 52 53 //Default Constructor 54 Triangle() 55 {side1 = 0.0; side2 = 0.0; side3 = 0.0;} 56 57 //Mutator functions 58void setSide1(float); 59void setSide2(float); 60void setSide3(float); 61 62 //Accessor functions 63float setSide1()const 64 {return side1;} 65float setSide2()const 66 {return side2;} 67float setSide3()const 68 {return side3;} 69 70float getTarea()const 71 {return (sqrt(((side1+side2+side3)/2)*(((side1+side2+side3)/2)-side1)*(((side1+side2+side3)/2)-side2)*(((side1+side2+side3)/2)-side3)));} 72 }; 73class Polygon 74 { 75private: 76double width; 77double length; 78 79public: 80 //Exception for negative 81class NegativeWidth 82 { }; 83 84class NegativeLength 85 { }; 86 87 //Default Constructor 88 Polygon() 89 {width = 0.0; length = 0.0;} 90 91 //Mutator functions 92void setWidth(double); 93void setLength(double); 94 95 //Accessor functions 96double getWidth()const 97 {return width;} 98double getLength()const 99 {return length;} 100 101double getParea()const 102 {return length * width;} 103 104 }; 105 #endif 106 107

GeometricArea.cpp

6 7 #include “GeometricArea.h” 8 9 //Exception for Circle 10void Circle :: setSide (double s) 11 { 12if (s >= 0) 13 side = s; 14else 15throw NegativeSize(); 16 } 17 //Exception for Triangle 18void Triangle :: setSide1 (float o) 19 { 20if (o >= 0) 21 side1 = o; 22else 23throw NegativeSide1(); 24 } 25 26void Triangle :: setSide2 (float t) 27 { 28if (t >= 0) 29 side2 = t; 30else 31throw NegativeSide2(); 32 } 33void Triangle :: setSide3 (float th) 34 { 35if (th >= 0) 36 side3 = th; 37else 38throw NegativeSide3(); 39 } 40 //Exception for Polygon 41void Polygon :: setWidth (double w) 42 { 43if (w >= 0) 44 width = w; 45else 46throw NegativeWidth(); 47 } 48 49void Polygon :: setLength (double len) 50 { 51if (len >= 0) 52 length = len; 53else 54throw NegativeLength(); 55 } 56

GeometricArea_test.cpp

6 7 #include 8 #include “GeometricArea.h” 9usingnamespace std; 10 11int main() 12 { 13 //assigning variables 14double side, sides, side1, side2, side3, width, length; 15char again, c; 16 17 18 Circle myCircle; 19 Triangle myTriangle; 20 Polygon myPolygon; 21 //to loop the whole thing 22do{ 23 cout << “Enter number of sides: “; 24 cin >> sides; 25 //Circle 26if (sides == 1 || sides == 0) 27 { 28 cout << “Enter diameter: “; 29 cin >> side; 30 } 31 //Triangle 32elseif (sides == 3) 33 { 34 cout << “Enter side 1: “; 35 cin >> side1; 36 cout << “Enter side 2: “; 37 cin >> side2; 38 cout << “Enter side 3: “; 39 cin >> side3; 40 } 41 //Polygon 42elseif (sides == 4) 43 { 44 cout << “Enter width: “; 45 cin >> width; 46 cout << “Enter length: “; 47 cin >> length; 48 } 49 //Getting area of Circle 50if (sides == 1 || sides == 0) 51 { 52try 53 { 54 myCircle.setSide(side); 55 cout << “The area of the circle is: ” 56 << myCircle.getArea() << endl; 57 cout << “Go again? (y/n): “; 58 cin >> again; 59 } 60 //For negative invalid values 61catch (Circle :: NegativeSize) 62 { 63 cout << “ERROR: A negative value was given for the circle’s side”; 64 } 65 } 66 //Getting area of Triangle 67if (sides == 3) 68 { 69try 70 { 71 myTriangle.setSide1(side1); 72 myTriangle.setSide2(side2); 73 myTriangle.setSide3(side3); 74 cout << “The area of the triangle is: ” 75 << myTriangle.getTarea() << endl; 76 cout << “Go again? (y/n): “; 77 cin >> again; 78 } 79 //For invalid negative values 80catch (Triangle :: NegativeSide1) 81 { 82 cout << “ERROR: A negative value was given for the triangle’s side 1”; 83 } 84catch (Triangle :: NegativeSide2) 85 { 86 cout << “ERROR: A negative value was given for the triangle’s side 2”; 87 } 88catch (Triangle :: NegativeSide3) 89 { 90 cout << “ERROR: A negative value was given for the triangle’s side 3”; 91 } 92 } 93 //Getting area of Polygon 94if (sides == 4) 95 { 96try 97 { 98 myPolygon.setWidth(width); 99 myPolygon.setLength(length); 100 cout << “The area of the polygon is: ” 101 << myPolygon.getParea() << endl; 102 cout << “Go again? (y/n): “; 103 cin >> again; 104 } 105 //For invalid negative values 106catch (Polygon :: NegativeWidth) 107 { 108 cout << “ERROR: A negative value was given for the polygon’s width”; 109 } 110catch (Polygon :: NegativeLength) 111 { 112 cout << “ERROR: A negative value was given for the polygon’s length”; 113 } 114 } 115 }while (again == ‘y’); 116 //to end program 117if (again == ‘n’) 118 cout << “End of Program” << endl; 119return 0; 120 } 121

Calculate the price
Make an order in advance and get the best price
Pages (550 words)
$0.00
*Price with a welcome 15% discount applied.
Pro tip: If you want to save more money and pay the lowest price, you need to set a more extended deadline.
We know how difficult it is to be a student these days. That's why our prices are one of the most affordable on the market, and there are no hidden fees.

Instead, we offer bonuses, discounts, and free services to make your experience outstanding.
How it works
Receive a 100% original paper that will pass Turnitin from a top essay writing service
step 1
Upload your instructions
Fill out the order form and provide paper details. You can even attach screenshots or add additional instructions later. If something is not clear or missing, the writer will contact you for clarification.
Pro service tips
How to get the most out of your experience with My Study Writers
One writer throughout the entire course
If you like the writer, you can hire them again. Just copy & paste their ID on the order form ("Preferred Writer's ID" field). This way, your vocabulary will be uniform, and the writer will be aware of your needs.
The same paper from different writers
You can order essay or any other work from two different writers to choose the best one or give another version to a friend. This can be done through the add-on "Same paper from another writer."
Copy of sources used by the writer
Our college essay writers work with ScienceDirect and other databases. They can send you articles or materials used in PDF or through screenshots. Just tick the "Copy of sources" field on the order form.
Testimonials
See why 20k+ students have chosen us as their sole writing assistance provider
Check out the latest reviews and opinions submitted by real customers worldwide and make an informed decision.
Social Work and Human Services
Although it took 2 revisions I am satisfied but I did receive it late because of that.
Customer 452603, March 25th, 2021
Business Studies
Thank you very much for a good job done and a quick turn around time.
Customer 452615, March 31st, 2021
Human Resources Management (HRM)
Very well written and very impressed with this service!
Customer 453077, February 16th, 2022
Economics
For some reason I did not get an email that the order was done, but it was on time regardless
Customer 453291, October 16th, 2022
Management
Love this writer!!! Great work
Customer 452597, April 5th, 2021
Business and administrative studies
awesome job
Customer 453201, June 24th, 2022
Emergency Management
Thanks
Customer 453015, October 28th, 2022
Psychology
Great paper, Thank you so much.
Customer 453209, October 4th, 2022
Business Studies
First of all, the writer made sure that he completely understood my assignment and all the guidelines before he began writing. My paper was finished very fast and well before the specified deadline. I thought it was written excellently. He definitely completely grasped the topic. Overall, he is a great writer and I couldn't have asked for better.
Customer 452441, November 29th, 2021
History
Looks great and appreciate the help.
Customer 452675, April 26th, 2021
Business Management
Awesome job, Thank you
Customer 453201, June 12th, 2022
Business Studies
Paper is great. Just only needed the one reference. Thank you
Customer 453139, May 4th, 2022
11,595
Customer reviews in total
96%
Current satisfaction rate
3 pages
Average paper length
37%
Customers referred by a friend
OUR GIFT TO YOU
15% OFF your first order
Use a coupon FIRST15 and enjoy expert help with any task at the most affordable price.
Claim my 15% OFF Order in Chat
Live ChatWhatsApp