Question: In C++ Create a C++ class Rectangle. The class has attributes length and width, with defaults to 1.0. It has member functions for calculating the
In C++

Create a C++ class Rectangle. The class has attributes length and width, with defaults to 1.0. It has member functions for calculating the perimeter and the area of a rectangle. It has setLength, setWidth, getLength, and getWidth functions for updating and accessing the length and width values. The set functions should verify that length/width are each floating-point numbers greater than 0.0 and less than 20.0. If an invalid value is encountered, the corresponding set function should return -1 to the calling function without changing the length/width values. Implement a main function that takes a data file name from command line argument. The main function reads the length and width values from this input file and use the Rectangle class to calculate the perimeter and area for each data set. (Note: the Rectangle class should not include any l/O codes. All IVOs should be done external to the Rectangle class) Source Files Rectangle.h - contains the Rectangle class declaration. Rectangle.cpp - contains the Rectangle class implementation. hw04.cpp - contains the main function and any other functions for file l/Os
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
