Write a Cylinder class having two data values: radius and height. Include the following functions in...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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 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
Expert Answer:
Related Book For
Posted Date:
Students also viewed these programming questions
-
Python and most Python libraries are free to download or use, though many users use Python through a paid service. Paid services help IT organizations manage the risks associated with the use of...
-
This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of an array of objects as a class data...
-
According to the Statute of Frauds, in order to be legally enforceable, a contract must be in writing, name the contracting parties, identify the subject matter of the contract, and Be for a legal...
-
Combine the Taylor polynomials from the previous set of problems with the leading behavior of the functions for large x to sketch graphs. g(x)
-
Assuring that the consent agreement procedure follows guidelines for social work within an organization for the use of social media and technology Explain how HIPAA and HITECH would be used in an...
-
Haar transform (a) For an \(N \times N\) Haar transformation matrix, the Haar basis functions are \[\psi_{k}(t)=\psi_{p q}(t)=\frac{1}{\sqrt{N}} \begin{cases}2^{p / 2}, & (q-1) / 2^{p} \leq t
-
One of Sure-Bet Sherbets best-selling products is raspberry sherbet, which is manufactured in 10-gallon batches. Each batch requires six quarts of raspberries. The raspberries are sorted by hand...
-
what ways can trauma-informed approaches inform resilience-building interventions, particularly in populations disproportionately affected by adversity ?
-
Suppose Vandyland is also interested in using monetary policy to combat the pandemic recession. When would you, the central bank, use quantitative easing? a. When interest rates are near zero and...
-
Identify the graph of the function. 5) f(x)-(x+3)3-2 A) -6 -6 A) -2,-1, 1,4 B) B) -1, 1,2,4 D) -6 Use a graphing calculator to approximate all real solutions of the equation f(x)=0. 6)...
-
Draw and calculate the two following gear trains. a.) Constraints: Input gear = 16 teeth; no two gears connected together can have a ratio of more than 6:1 ; Input gear = 10 rad/sec Make a simple...
-
Apply the Ampere's Circuital Law to determine H. dl for the currents and closed paths l1, l2, and l3 in Figure Q1(b). 10 A O 10 A O 10 A O 30 A 10 A O 30 A l3 Figure Q1(b) 10 A 10 A O 10 A 30 A 10 A...
-
(1 point) How many pivot variables does each augmented matrix have? 1 -2 -5 a. Choose 0 0 0 0 0 0 1 b. Choose 0 0 c. Choose d. Choose 1 0 0 1 -7 0 0 0 0 -2 3 0 0 0 0 8 -7 00 -4 0 1 0 10 0 2 7 3 0 1 0...
-
Suppose we have the following predicates and the universe where all of the objects are people : (i) study(X) -------------> X study diligently (v) poor(X) --> X is not poor (ii) -stupid(X). -> X is...
-
Why do you think Altria Group made Kraft its own company? Do you think it had anything to do with the mix of businesses in which then-parent Altria Group was involved? Why or why not?
-
Carlton Stokes owns and operates a car-detailing business named SuperShine & Detailing. For $150, Carltons business will hand wash and wax customers cars, vacuum the interior, and thoroughly clean...
-
Natasha Kingery is 30 years old and has a Bachelor of Science degree in computer science. She is currently employed as a Tier 2 field service representative for a telephony corporation located in...
-
This is your second interview with a prestigious brokerage firm for a job as an equity analyst. You survived the morning interviews with the department manager and the vice president of equity....
-
The following data from Lyre Ltd's accounts relates to two assets at 30 June 2023. At 30 June 2023 Lyre Ltd decides to adopt the revaluation model for both these assets. On this date land has a fair...
Study smarter with the SolutionInn App