Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
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