c++ exercise: 1- Implement the class “cylinder” with member variables radius and height, which are private of type double. Define the global constant PI=3.1415 and use it in calculating the volume of the cylinder (PI*radius*radius*height). Implement in the class cylinder the following functions: a- A default constructor with default values of one. b- One constructor with two arguments. This constructor should check that the variable is positive and does not exceed 20, otherwise the variable will be assigned its default value of one. c- A reader for each variable. d- A writer for each variable. e- A reader and a writer for diameter. f- A member function “volume” which calculates the volume of a cylinder. g- A member function “print” which prints the radius, diameter, and height of a cylinder. h- A member function display_name() which displays “cylinder

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter13: Overloading And Templates
Section: Chapter Questions
Problem 6PE
icon
Related questions
Question

c++ exercise:

1- Implement the class “cylinder” with member variables radius and height, which
are private of type double. Define the global constant PI=3.1415 and use it in
calculating the volume of the cylinder (PI*radius*radius*height).
Implement in the class cylinder the following functions:
a- A default constructor with default values of one.
b- One constructor with two arguments. This constructor should check that the
variable is positive and does not exceed 20, otherwise the variable will be
assigned its default value of one.
c- A reader for each variable.
d- A writer for each variable.
e- A reader and a writer for diameter.
f- A member function “volume” which calculates the volume of a cylinder.
g- A member function “print” which prints the radius, diameter, and height of a
cylinder.
h- A member function display_name() which displays “cylinder

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps with 1 images

Blurred answer
Knowledge Booster
Class
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning