Question: Write a Cylinder class having two data values: radius and height. Include the following functions in the class. a. (10 pts) Write two constructors.

Write a Cylinder class having two data values: radius and height. Include 

Write a Cylinder class having two data values: radius and height. Include the following functions in the class. a. (10 pts) Write two constructors. Default constructor should set radius to 5 and height to 10. Explicit-value constructor should accept two parameters and sets those values as the radius and height of the cylinder. However, if the radius is less than or equal to 0, the constructor should print an error message and sets it to 5. If the height is less than or equal to 0, the constructor should print an error message and sets it to 10. b. (10 pts) Write getters and setters for the radius and height such as getRadius, setRadius, getHeight, and setHeight. If the parameter of setRadius or setHeight is not positive, do not change the radius or height and print an error message. c. (5 pts) Write two functions getSurface Area and getVolume that returns the surface area and volume of the cylinder, respectively. d. (10 pts) Write a function named isSmaller that takes a Cylinder c as parameter and returns true if volume of the cylinder object (this) is smaller than the volume of Cylinder c (parameter), false otherwise. Activate Windows e. (5 pts) Write a function named display to print the cylinder objects by displaying all data members. For a cylinder with radius 3 and height 5, it should display: "radius: 3, height: 5". The function returns nothing. Go to Settings to activate W

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 Programming Questions!