C++ Create a class Rectangle. The class has attributes length and width, each of which defaults to 1. It has member functions that calculate the perimeter and the area of the rectangle. It has setter and getter functions for both length and width. The program should ASK THE USER TO INPUT length and width value. The set functions should verify that length and width are each floating-point numbers larger than 0.0 and less than 20.0. A sample output of your program should look like follows: length = 1.0; width = 1.0; perimeter = 4.0; area = 1.0 another example: length = 5.0; width = 4.0; perimeter = 18.0; area = 20.0 There should be three files and ONE class only. .h file contains class definition, .cpp file contains the implementation of the class in .h file and main.cpp should contain the driver code.
C++
Create a class Rectangle. The class has attributes length and width, each of which defaults to 1. It has member functions that calculate the perimeter and the area of the rectangle. It has setter and getter functions for both length and width. The program should ASK THE USER TO INPUT length and width value. The set functions should verify that length and width are each floating-point numbers larger than 0.0 and less than 20.0.
A sample output of your program should look like follows:
length = 1.0; width = 1.0; perimeter = 4.0; area = 1.0
another example:
length = 5.0; width = 4.0; perimeter = 18.0; area = 20.0
There should be three files and ONE class only.
.h file contains class definition, .cpp file contains the implementation of the class in .h file and main.cpp should contain the driver code.
Trending now
This is a popular solution!
Step by step
Solved in 2 steps