Answered step by step
Verified Expert Solution
Link Copied!

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 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
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Practical Database Programming With Visual Basic.NET

Authors: Ying Bai

1st Edition

0521712351, 978-0521712354

More Books

Students also viewed these Databases questions