I've been working on this for a couple of months..........
It figures out the Area, Radius, Diameter, and Circumference
of a Circle..........enjoy.......
Code:
// Dimensional calulator. v6.2
// Dimension.c - 320mb 16 - 6 - 2004
#include <iostream.h>
#include <math.h>
const float pi = 3.141592653589793238;
int option,pause;
float rad,area,circum,diam = 0;
double radsq,x = 0;
char radmsg[] ="\nThe radius of this circle is ";
char cirmsg[] ="\nThe circumference of this circle is ";
char diamsg[] ="\nThe diameter of this circle is ";
char aremsg[] ="\nThe area of this circle is ";
int main()
{
cout << "Calculate Circle Dimensions v6.2. by Stanley Clark\n\n";
cout << "Please choose a valid option from below ... \n\n";
cout << " To find the properties from the radius type: 1\n";
cout << " To find the properties from the diameter type: 2\n";
cout << " To find the properties from the circumference type: 3\n";
cout << " To find the properties from the area type: 4\n";
cout << " To exit please type: 5 \n\n";
cin >> option;
switch (option)
{
case 1:
cout << "\nPlease enter the radius of a circle in milimetres? ";
cin >> rad;
cout << "\nYou entered the radius as " << rad << " mm....\n";
diam = rad * 2; // Calculate diameter
cout << diamsg << diam << " mm\n";
circum = 2 * pi * rad; // Calculate circumference
cout << cirmsg << circum << " mm\n";
area = rad * rad * pi; // Calculate area
cout << aremsg << area << " mm^2\n";
break;
case 2:
cout << "\nPlease enter the diameter of a circle in milimetres? ";
cin >> diam;
cout << "\nYou entered the diameter as " << diam << " mm....\n";
rad = diam / 2; // Calculate radius
cout << radmsg << rad << " mm\n";
circum = pi * diam; // Calculate circumference
cout << cirmsg << circum << " mm\n";
area = rad * rad * pi; // Calculate area
cout << aremsg << area << " mm^2\n";
break;
case 3:
cout << "\nPlease enter the circumference of a circle in milimetres? ";
cin >> circum;
cout << "\nYou entered the circumference as " << circum << " mm....\n";
rad = circum / 2 / pi; // Calculate radius
cout << radmsg << rad << " mm\n";
diam = rad * 2; // Calculate diameter
cout << diamsg << diam << " mm\n";
area = rad * rad * pi; // Calculate area
cout << aremsg << area << " mm^2\n";
break;
case 4:
cout << "\nPlease enter the area of a circle in milimetres squared? ";
cin >> area;
cout << "\nYou entered the area as " << area << " mm^2....\n";
radsq = area / pi; // Calculate radius
cout << radmsg << sqrt(radsq) << " mm\n";
rad = radsq;
diam = sqrt(radsq) * 2; // Calculate diameter
cout << diamsg << diam << " mm\n";
circum = 2 * pi * sqrt(radsq); // Calculate circumference
cout << cirmsg << circum << " mm\n";
break;
case 5:
return 0;
}
}