Question

In: Computer Science

Write a program that reads the radius of a sphere and calculates it's volume and surface...

Write a program that reads the radius of a sphere and calculates it's volume and surface area. Format results to 4 decimal places. The radius=3.2 Your program should output volume and surface area.  Repeat same steps for program2, but this time use the following input values:

a= ꟷ2.4 , b = 4.5 . Your program should output sum, Fun1, and Fun2. It's for C++

Solutions

Expert Solution

Answer:

Please post the program2 correctly no sufficient infromation

Here is the c++ code for program one

Raw code:

//headers

#include <iostream>

#include<iomanip>

//namespace standard

using namespace std;

//pi constant

const float PI = 3.14;

//function to calculater surfaceArea

float surface_area(float radius){

float surfaceArea=4*PI*(radius*radius);

return surfaceArea;

}

//function to calculate volume of sphere

float volume(float radius){

float vol=4/3*PI*(radius*radius*radius);

return vol;

}

//main

int main() {

//setting precison to 5 to show upto four decimal points

cout<<setprecision(5)<<endl;

//radius

float radius=3.2;

//calling function passing the radius

cout<<"Surface area: "<<surface_area( radius)<<endl;

cout<<"Volume: "<<volume(radius)<<endl;

}

Editor:

output:

Hope this helps you! If you still have any doubts or queries please feel free to comment in the comment section.

"Please refer to the screenshot of the code to understand the indentation of the code".

Thank you! Do upvote.


Related Solutions

Write a C++ program to calculate the sphere volume and surface area. Provided that the sphere...
Write a C++ program to calculate the sphere volume and surface area. Provided that the sphere volume = and the sphere surface area = , where r is the radius. 1. Read r from the user using cin statement. 2. Calculate the volume (Vol) and the surface area (Area) of a sphere. 3. Print r, Vol, and Area in a suitable messages.
Write a program that reads in the radius and length of a cylinder and computes volume...
Write a program that reads in the radius and length of a cylinder and computes volume using the following formulas: area = radius * radius * PI volume = area * length
The surface area of a sphere of radius r is S = 4πr2. Its volume is
The surface area of a sphere of radius r is S = 4πr2. Its volume is V = 4πr3/3. a. Use MuPAD to find the expression for dS/dV. b. A spherical balloon expands as air is pumped into it. What is the rate of increase in the balloon’s surface area with volume when its volume is 30 in.3?
A sphere of radius r has surface area A = 4πr2 and volume V = 4...
A sphere of radius r has surface area A = 4πr2 and volume V = 4 3 πr3. The radius of sphere 2 is triple the radius of sphere 1. (a)What is the ratio of the areas, A2/A1? (b) What is the ratio of the volumes, V2/V1?
Write a JavaScript function to calculate the surface area of a sphere. Input the radius using...
Write a JavaScript function to calculate the surface area of a sphere. Input the radius using a NumericUpDown. Have the function calculate the surface area and display it on your page. Label the inputs and the output on your page. Change the title to "Oh, Boy! JavaScript!". Put your name at the top in camelCase. Put your major at the bottom in camelCase.
A charge Q is distributed in the volume of a sphere of radius R with a...
A charge Q is distributed in the volume of a sphere of radius R with a density non-uniform load cubic p = B (R - r) , where b is a constant and r is the distance to the center of the sphere determine: The values ​​of the potential in the center and on the surface of the sphere.
Find the distribution of temperature inside a sphere of radius a when the surface of the...
Find the distribution of temperature inside a sphere of radius a when the surface of the upper half is held at 100°C and the surface of the lower half at 0°C
Consider a particle which is constrained to move along the surface of the sphere of radius...
Consider a particle which is constrained to move along the surface of the sphere of radius 5, centered at the origin. (a) If we write r(t) for the motion, write down the condition ‘constrained to move along the surface of the sphere of radius 5 centered at the origin’ in terms of r(t). (Hint. For later use, try to get rid of square roots.) (b) Explain why, for such a motion, we must have r 0 (t) ⊥ r(t). (Hint....
7.1.2. A pulsating sphere of radius a vibrates with a surface velocity amplitude U0 and at...
7.1.2. A pulsating sphere of radius a vibrates with a surface velocity amplitude U0 and at such a high frequency that ka >> 1. Derive expressions for the pressure amplitude, the particle velocity amplitude, the intensity, and the total acoustic power radiated in the resulting acoustic wave.
If a charge "Q" is removed from the inside surface of a hollow sphere of radius...
If a charge "Q" is removed from the inside surface of a hollow sphere of radius "a" with infinite conductivity. (a)How much force is required to remove the charge from the sphere? (b)How much work is done to move the charge to a radius of infinity?
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT