develop a VI that computes the surface area and volume Devel

develop a VI that computes the surface area and volume
Develop a VI that computes the surface area and volume of a sphere. The only input is the sphere diameter, denoted by d. The VI should have one numeric control and two numeric indicators. The volume of a sphere is V = 4/3 pi r^3. where r = d/2 is the radius of the sphere. The surface area is given by S = 4 pi r^2 Save the VI as Sphere.vi in the Users Stuff folder in the Learning directory.

Solution

c pgm:

#include <stdio.h>
#include <math.h>

int main()
{

float radius;
float surface_area, volume;

printf(\"Enter radius : \");
scanf(\"%f\", &radius);
surface_area = 4 * (22/7) * radius * radius;
volume = (4.0/3) * (22/7) * radius * radius * radius;
printf(\"Surface area of sphere is: %.3f\", surface_area);
printf(\"\ Volume of sphere is : %.3f\", volume);
return 0;
}

java code:

public class Sphere {
public static void main(String[] args) {
final double PI = 3.14159;

double radius;
double surface_Area, volume_sphere;

System.out.print(\"Enter the radius : \");
Scanner input = new Scanner(System.in);
radius = input.nextDouble();


surface_Area = 4 * PI * radius * radius;
volume_sphere = (4.0 / 3.0) * PI * radius * radius * radius;

System.out.println(\" radius \" + radius + \",surface area is \" + surfaceArea + \"volume is \"
+ volume_sphere + \".\");
}
}

develop a VI that computes the surface area and volume Develop a VI that computes the surface area and volume of a sphere. The only input is the sphere diameter

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site