Question: Design a C + + class to manage measurements. The class should have two integer data members: feet and inches. It must ensure that the

Design a C++ class to manage measurements. The class should have two integer data
members: feet and inches. It must ensure that the inches attribute remains within the
range of 0 to 11, adjusting the feet attribute accordingly if necessary. This implies that
feet might become negative.
Implement two constructors for the class:
A default constructor that initializes both and to zero.
A constructor that takes one integer argument representing the total number of
inches.
Ensure that the class handles conversions between feet and inches appropriately and
maintains the constraints specified above.
Additionally, in the main function, after creating instances of the class using both
constructors, test the setter method for feet by setting it to a negative value and
displaying the updated measurements.
Example Outputs:
Sample Execution 1: Default Constructor
Measurement m1;
m1.display(); // Output: 0 feet, 0 inches
Output:
0 feet, 0 inches
Sample Execution 2: Constructor with Total Inches
Sample Execution 3: Setter Method for Feet
Output:
-2 feet, 1 inch
Sample Execution 4: Setter Method for Inches
 Design a C++ class to manage measurements. The class should have

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!