// Calculation Program for the volume of an egg body, 30(Mon.) Nov., 2009
// egg equation: (x*x+y*y)**2=a*(x**3)+(a-b)*x*(y**2), The case that a=4 and b=3.2 (or, a=1 and b=0.8) may be the nearest shape to an actual egg.
// The general condition needs b<=a, and in the case of b=0, the curve is led to a circle.
// file name: volume.c
#include< stdio.h>
#include< math.h>
void main(void)
{
double a,b,v,pi;
// Setting of the constants
for(;;)
{
printf("Input of constant a; a= ? ");
scanf("%lf",&a);
if(a>0)
{
break;
}
else
{
printf("Please input the value of a after correcting a as a>0.\n");
}
}
for(;;)
{
printf("Input of constant b; b= ? ");
scanf("%lf",&b);
if(b>=0&&b<=a)
{
break;
}
else
{
printf("Pleease input the value of b after correcting b as 0< b < a or b=0 or b=a.\n");
}
}
printf("\n");
pi=3.1415927;
// execution of calculation
if(b==0)
{
v=pi*a*a*a/6;
}
else
{
v=(pi/2)*((a+b)*(a+b)*(a+b)*a/(6*b)-a*a*a/6-a*a*b/2-((a+b)*(a+b)*(a+b)*(a+b)*(a+b)-(a-b)*(a-b)*(a-b)*(a-b)*(a-b))/(60*b*b));
}
printf("The volume of the egg is ; V=%lf\n",v);
printf("\n");
printf("end\n");
}// the end of the program
RETURN