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 most basic C++ program possible that calculates volume and surface area of five shapes (Cube,...
Write most basic C++ program possible that calculates volume and surface area of five shapes (Cube, Sphere, Prism, Cylinder, Cone), where each shape has its own class (with a volume function, surface area function, constructor, as well as get and set functions), and the shape dimensions are private class members. Include input and display functions.
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.
Write a pyhton program that reads a stream of bits, e.g. 11001, and calculates and prints...
Write a pyhton program that reads a stream of bits, e.g. 11001, and calculates and prints the decimal value of the binary number represented by the entered bits, i.e. 25 in this case.
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.
A sphere with radius a has uniform charge/volume. A metal sphere shell has inner radius b(from...
A sphere with radius a has uniform charge/volume. A metal sphere shell has inner radius b(from center) and outer radius c(from center). Between a and b is empty. Outer metal shell has total charge Q1 Please start with Gauss's law and show steps Find Electric field in region a) r<a b)a<r<b c)b<r<c d) r>c
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
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT