Volume of hollow sphere given by
4/3 *pi*(Ro^3 –Ri^3 )
where Ro is the outer radius, and
Ri is the inner radius
Write a program that prompt user for these two radii, then call a function to calculate volume, and print result. If you enter inner radius larger than outer radius, or negative numbers as radius then warn the user that the radii entered are invalid, and prompt user to reenter radii. Your function calculates the volume of the hollow sphere.
Here is your code..
#include<iostream>
using namespace std;
float volume(float Ro, float Ri)
{
float vol,pi = 3.14159;
float a= ((Ro*Ro*Ro)-(Ri*Ri*Ri));
vol = (float(4)/float(3)) * pi * a;
return vol;
}
int main()
{
float radius1, radius2;
s: cout<<"Enter radius1(Inner radius) : ";
cin>>radius1;
cout<<"Enter radius2(Outer radius) : ";
cin>>radius2;
if((radius1>radius2) || (radius1<0) ||
(radius2<0))
{
cout<<"Entered radius is
invaid.Please enter it again"<<endl;
goto s;
}
else
{
float
v=volume(radius2,radius1);
cout<<"Volume Of Hollow
Sphere is :" << v << endl;
}
return 0;
}
Volume of hollow sphere given by 4/3 *pi*(Ro^3 –Ri^3 ) where Ro is the outer radius,...
A hollow sphere of inner radius b and outer radius a is subject to normal pressures on its inner and outer surfaces. The sphere is made up of an isotropic material, the displacements and stress fields are spherically symmetric. The only non-vanishing displacement component is the radial displacement ur, and is a function of r only. Based on this we can assume the following strains. lu lur dr The only non-vanishing stress components are the radial stress σ, and the...
A hollow sphere of inner radius b and outer radius a is subject to normal pressures on its inner and outer surfaces. The sphere is made up of an isotropic material, the displacements and stress fields are spherically symmetric. The only non-vanishing displacement component is the radial displacement ur, and is a function of r only. Based on this we can assume the following strains. lu lur dr The only non-vanishing stress components are the radial stress σ, and the...
An insulating hollow sphere of inner radius R1 and outer radius R2 has a uniform volume charge density pand carries a total positive charge Q. A. Calculate the magnitude of the electric field and the electric flux at a point r where: B. Sketch the electric field and the electric flux as a function of r.
A hollow insulating spherical shell of inner radius R0 and outer radius R1 is positively charged with a charge density of p(r) = p0(1 – (r/R1)3). A positive charge +Q is placed in the center of the hollow sphere and a concentric grounded conducting shell with inner radius R2 and outer radius R3 surrounds the hollow sphere. (The conducting shell was neutral before it is grounded.) (a) What is the total charge on the insulating sphere? (b) What charges are on the...
Problem: Write a short C++ program that gets the side of a cube and the radius of a sphere from the keyboard and writes to a file the surfaces of these shapes. ------------------------------------------------------------------------------------------------------------------------ Your task: implement in C++ the algorithm solution shown below. ------------------------------------------------------------------------------------------------------------------------ Part A (79 points) Algorithm solution (in pseudocode): To accomplish this task, your program will have to take the following steps: 1. Declare a variable named outFile that represents an output stream. 2. Declare a...
Write a program in C++. You need everything everythihng given You will create a function that validates input. It should accept only non-negative integers. If the input is incorrect the function should throw an exception. The exception will not be caught in the function. You will create a function that reads in 2 integer values. One is a number that will be raised to the power of the second. So if 5 and 6 are entered the result would be...
#1 and #3 I) )A solid insulating sphere of radius a carries a net positive charge density 3p uniformly distributed throughout its volume. A conducting spherical shell of inner radius 2a and outer radius 3a is concentric with the solid sphere and carries a net charge density-22 Using Gauss's law, find the electric field everywhere. Sketch the electric field 2) "A) The current density in a cylindrical wire of radius R meters is uniform across a cross section of the...
Python 3: Please follow the respective rubric for the following function definition. Rubric: Rectangle Shape You should implement the following functions to print a rectangle shape. • print_rectangle(length, width, fillChar, hollow). This function will use draw_shape_line() function to print a rectangle shape with the given length and width, If the hollow is true, the shape will be hollow rectangle, otherwise a filled rectangle. This function must not interact with the user. For example, the call print_rectangle(5, 10, '*', False) should...
C++ programming For this assignment, write a program that will act as a geometry calculator. The program will be menu-driven and should continue to execute as long as the user wants to continue. Basic Program Logic The program should start by displaying a menu similar to the following: Geometry Calculator 1. Calculate the area of a circle 2. Calculate the area of a triangle 3. Quit Enter your choice(1-3): and get the user's choice as an integer. After the choice...
Nay programming languge is fine (MatLab, Octave, etc.) This is the whole document this last picture i sent is the first page 5. Write and save a function Sphere Area that accepts Radius as input argument, and returns SurfaceArea (4 tt r) as output argument. Paste the function code below. Paste code here 6. Validate your Sphere Area function from the command line, checking the results against hand calculations. Paste the command line code and results below. 7. Design an...