Question: Write a program, circle.cpp, that inputs double radius of circle. It should print for given this radius, the circumference of the circle, the area of

Write a program, circle.cpp, that inputs double radius of circle. It should print for given this radius, the circumference of the circle, the area of the circle, the surface area of a sphere with that radius and the area of a sphere with that radius.

Here are the formulas for computation: Circumference = 2 ? r Circle Area = ? r Sphere Surface Area = 4 ? r2 Sphere Volume = 4/3 ? r Define a constant for ? before main in your program: const double pi = 3.14159265358;

You are required to write functions that do the following: ? compute and return the circumference of a circle given the radius (parameter) ? compute and return the area of a circle given the radius (parameter) ? compute and return the sphere surface area given the radius (parameter) ? compute and return the sphere area given the radius (parameter) ? print the results given the values of the circumference, area, surface, and volume (four parameters, no return value) A sample run might be (user input in bold):

Enter a radius: 7.5 Circumference .... 47.124 Circle Area ...... 176.715 Sphere Surface ... 706.858 Sphere Volume .... 1767.146 The output should follow the format shown above (values printed with 3 digits after the decimal, in a field width of 10 characters). 5 points extra credit: Add an input driven loop that will allow the user to compute results for a number of radii (until the radius entered is less than or equal 0).

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