Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 to 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 : Default Constructor
Measurement m;
mdisplay; Output: feet, inches
Output:
feet, inches
Sample Execution : Constructor with Total Inches
Sample Execution : Setter Method for Feet
Output:
feet, inch
Sample Execution : Setter Method for Inches
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started