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++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter6: Modularity Using Functions
Section6.2: Returning A Single Value
Problem 13E
icon
Related questions
Question

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.

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
ADT and Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr
EBK JAVA PROGRAMMING
EBK JAVA PROGRAMMING
Computer Science
ISBN:
9781337671385
Author:
FARRELL
Publisher:
CENGAGE LEARNING - CONSIGNMENT
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
Microsoft Visual C#
Microsoft Visual C#
Computer Science
ISBN:
9781337102100
Author:
Joyce, Farrell.
Publisher:
Cengage Learning,