Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

C++ PROGRAMMING: PLEASE MAKE SURE THE PROGRAM COMPILES AND RUNS FOR 5 STARS :-) HERE IS THE CODE TO EDIT BELOW (PLEASE ONLY ADD CODE):

C++ PROGRAMMING: PLEASE MAKE SURE THE PROGRAM COMPILES AND RUNS FOR 5 STARS :-)

image text in transcribed

HERE IS THE CODE TO EDIT BELOW (PLEASE ONLY ADD CODE):

#include #include using namespace std; class DimError { private: string message; public: //implement the methods }; class Rectangle { private: int length, width; public: //implement the methods }; int main(void) { Rectangle r; try { while (true) { int l, w; cout > l; cout > w; r.setLength(l); r.setWidth(w); cout  

objectives: 1. Handling exceptions within a pro 2. Using trylcatch block 3. Creating exception class Question: Design a program that repeatedly asks for the dimensions (length and width of a rectangle and computes the area. Consider a class Rectangle which includes the following two functions: void Rectangle setWidth (int width) void Rectangle setLength (int length) If the length and width are positive, then above functions store the values in the Rectangle object. However, if the length and width are negative, the functions throw an object of Dim.Error class that includes a message indicating which method was called and the reason for the error. Note: DimError class is used by the Rectangle class for showing error messages

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

Inductive Databases And Constraint Based Data Mining

Authors: Saso Dzeroski ,Bart Goethals ,Pance Panov

2010th Edition

1489982175, 978-1489982179

More Books

Students also viewed these Databases questions