3) (10 pts) Develop and algorithm to calculate the surface area and internal vol
ID: 3855757 • Letter: 3
Question
3) (10 pts) Develop and algorithm to calculate the surface area and internal volume of a torus. A torus is a 3-dimensional surface created by revolving a circle through its center around an axis coplanar with the circle. An example of a torus is depicted in Figure 1. The formulae to calculate the volume and area of a ring or horn torus are Where: A: V: R: Surface area of the torus (in squared units of length) Internal volume of the torus (in cubic units of length) Major radius. Represents the distance from the center of the tube to the center of the torus (in units of length) Figure 1:A ring torus : Minor radius. Represents the radius of the tube (in units of length) t: Mathematical constant approximately equal to 3.1416 The algorithm must display the area and volume. It must also determine the type of torus based on the relationship between the two radii (see Table 1 and Figure 2). Finally, if the type of torus is "Spindle" the algorithm must display the message "Calculated area and volume may be overstated Table 1. Types of tori based relationship between R and r RelationshipType of Torus RT R=Y Rin Horn SpindleExplanation / Answer
#include <stdio.h>
int main()
{
const double pi = 3.1416;
double x,y,area,volume;
printf ("Enter the Major Radius (in units of length) : ");
scanf("%lf",&x);
printf ("Enter the Minor Radius (in units of length) : ");
scanf("%lf",&y);
area = ((2*pi*x) * (2*pi*y));
volume = (pi*y*y) * (2*pi*x);
printf ("Area of Torus : %lf (meter)^2 ",area);
printf ("Volume of Torus : %lf (meter)^3 ",volume);
if (x>y)
printf("Type of torus : Ring ");
else if (x==y)
printf("Type of torus : Horn ");
else
{
printf("Type of torus : Spindle ");
printf("Calculated Area and Volume may be overstated ");
}
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.