Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a C++ program USING OVERLOADED FUNCTIONS to compute the side area and volume of a cylinder and the area and volume of a sphere,

Write a C++ program USING OVERLOADED FUNCTIONS to compute the side area and volume of a cylinder and the area and volume of a sphere, depending on the choice that the user makes. Your program should ask users to enter 1 to choose cylinder or 2 for sphere, and display an invalid choice error for other values.

For a cylinder, we want to compute: Side area: (2r)h, Volume: (r2 )h, where r is the radius of the cylinder and h is the height of the cylinder.

For a sphere, we want to compute: Surface area: 4r2 , Volume: (4.0/3.0)r3 , where r is the radius of the sphere. It is required to use overloading functions to write the program for the above problem.

Sample Input/Output: Test Case 1: Enter 1 for cylinder and 2 for sphere: 2 Enter the radius of a sphere: 5 The surface area of the sphere is 314.159 The volume of the sphere is 523.598

Test Case 2: Enter 1 for cylinder and 2 for sphere: 1 Enter the radius and the height of a cylinder: 4 5 The side area of the cylinder is 125.664 The volume of the cylinder is 251.327

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

More Books

Students also viewed these Databases questions