#include <stdio.h>
/* Kanyaphat Ongsantpap*/
/* 66070503015 CHE */
float cubeVolume( ) ;
float cylinderVolume( ) ;
float prismVolume( ) ;
float sphereVolume( ) ;
float pyramidvolume( ) ;
float coneVolume( ) ;
#define PI 3.14
float cube ;
float cylinder, prism, sphere, pyramid, cone;
float a, rC, h, base, height, rS, basep, heightp, rCone, hcone;
int main( void ) {
int i;
printf ( "Press 1 to find Volume of Cube\n Press 2 to find Volume of Cylinder\n Press 3 to find Volume of Prism\n Press 4 to find Volume of sphere\n Press 5 to find Volume of Pyramid\n Press 6 to find Volume of Cone\n Press 0 to exit the program\n " ) ; switch ( i) {
case 1 : {
float cube = cubeVolume( ) ;
if ( cube >= 0.01 ) {
printf ( "The Volume of Cube is %0.2f" , cube
) ; }
}
break ;
case 2 : {
printf ( "Radius of the Cylinder:" ) ; printf ( "Height of the Cylinder:" ) ; float cylinder = cylinderVolume( ) ;
if ( cylinder >= 0.01 ) {
printf ( "The Volume of Cylinder is %0.2f" , cylinder
) ; }
}
break ;
case 3 : {
printf ( "Area base of pryamid:" ) ; printf ( "Height of the Prism:" ) ; float prism = prismVolume( ) ;
if ( prism >= 0.01 ) {
printf ( "The Volume of Prism is %0.2f" , prism
) ; }
}
break ;
case 4 : {
printf ( "Radius of the Sphere:" ) ; float sphere = sphereVolume( ) ;
if ( sphere >= 0.01 ) {
printf ( "The Volume of Sphere is %0.2f" , sphere
) ; }
}
break ;
case 5 : {
printf ( "Base of the Pyramid:" ) ; printf ( "Height of the Pyramid:" ) ; float pyramid = pyramidvolume( ) ;
if ( pyramid >= 0.01 ) {
printf ( "The Volume of Pyramid is %0.2f" , pyramid
) ; }
}
break ;
case 6 : {
printf ( "Radius of the Cone:" ) ; printf ( "Height of the Cone:" ) ; float cone = coneVolume( ) ;
if ( cone >= 0.01 ) {
printf ( "The Volume of Cone is %0.2f" , cone
) ; }
}
break ;
case 0 :
printf ( "Exiting the program" ) ; break ;
}
return 0 ;
}
float cubeVolume( ) {
return a* a* a;
}
float cylinderVolume( ) {
return PI* rC* rC* h;
}
float prismVolume( ) {
return base* height;
}
float sphereVolume( ) {
return 4.00 / 3.00 * PI* rS* rS* rS;
}
float pyramidvolume( ) {
return 1.00 / 3.00 * basep* heightp;
}
float coneVolume( ) {
return 1.00 / 3.00 * PI* rCone* rCone* hcone;
}
I2luY2x1ZGUgPHN0ZGlvLmg+Ci8qIEthbnlhcGhhdCBPbmdzYW50cGFwKi8KLyogNjYwNzA1MDMwMTUgQ0hFICovCiAKCmZsb2F0IGN1YmVWb2x1bWUoKTsKZmxvYXQgY3lsaW5kZXJWb2x1bWUoKTsKZmxvYXQgcHJpc21Wb2x1bWUoKTsKZmxvYXQgc3BoZXJlVm9sdW1lKCk7CmZsb2F0IHB5cmFtaWR2b2x1bWUoKTsKZmxvYXQgY29uZVZvbHVtZSgpOwojZGVmaW5lIFBJIDMuMTQKICBmbG9hdCBjdWJlIDsKICBmbG9hdCBjeWxpbmRlciwgcHJpc20sIHNwaGVyZSwgcHlyYW1pZCxjb25lOwogIGZsb2F0IGEsIHJDLCBoLCBiYXNlLCBoZWlnaHQsIHJTLCBiYXNlcCwgaGVpZ2h0cCwgckNvbmUsIGhjb25lOwppbnQgbWFpbih2b2lkKSB7CiAgaW50IGk7CiAgcHJpbnRmKCJQcmVzcyAxIHRvIGZpbmQgVm9sdW1lIG9mIEN1YmVcblByZXNzIDIgdG8gZmluZCBWb2x1bWUgb2YgQ3lsaW5kZXJcblByZXNzIDMgdG8gZmluZCBWb2x1bWUgb2YgUHJpc21cblByZXNzIDQgdG8gZmluZCBWb2x1bWUgb2Ygc3BoZXJlXG5QcmVzcyA1IHRvIGZpbmQgVm9sdW1lIG9mIFB5cmFtaWRcblByZXNzIDYgdG8gZmluZCBWb2x1bWUgb2YgQ29uZVxuUHJlc3MgMCB0byBleGl0IHRoZSBwcm9ncmFtXG4iKTsKICBzY2FuZigiJWQiLCAmaSk7CiAgIHN3aXRjaChpKXsKICAgICBjYXNlIDE6IHsKICAgICAgIAogICAgICAgIHByaW50ZigiU2lkZSBvZiB0aGUgY3ViZToiKTsKICAgICAgICBzY2FuZigiJWYiLCAmYSk7CiAgICAgICAgZmxvYXQgY3ViZSA9IGN1YmVWb2x1bWUoKTsKICAgICAgIGlmKGN1YmUgPj0gMC4wMSl7CiAgICAgICAgcHJpbnRmKCJUaGUgVm9sdW1lIG9mIEN1YmUgaXMgJTAuMmYiLCBjdWJlKTsKICAgICAgIH0KICAgICB9CiAgICAgYnJlYWs7CiAgICAgY2FzZSAyOnsKICAgICAgICBwcmludGYoIlJhZGl1cyBvZiB0aGUgQ3lsaW5kZXI6Iik7CiAgICAgICAgc2NhbmYoIiVmIiwgJnJDKTsKICAgICAgICBwcmludGYoIkhlaWdodCBvZiB0aGUgQ3lsaW5kZXI6Iik7CiAgICAgICAgc2NhbmYoIiVmIiwgJmgpOwogICAgICAgIGZsb2F0IGN5bGluZGVyID0gY3lsaW5kZXJWb2x1bWUoKTsKICAgICAgIGlmKGN5bGluZGVyID49IDAuMDEpewogICAgICAgIHByaW50ZigiVGhlIFZvbHVtZSBvZiBDeWxpbmRlciBpcyAlMC4yZiIsIGN5bGluZGVyKTsKICAgICAgIH0KICAgICB9CiAgICAgYnJlYWs7CiAgICAgY2FzZSAzOnsKICAgICAgICBwcmludGYoIkFyZWEgYmFzZSBvZiBwcnlhbWlkOiIpOwogICAgICAgIHNjYW5mKCIlZiIsICZiYXNlKTsKICAgICAgICBwcmludGYoIkhlaWdodCBvZiB0aGUgUHJpc206Iik7CiAgICAgICAgc2NhbmYoIiVmIiwgJmhlaWdodCk7CiAgICAgICAgZmxvYXQgcHJpc20gPSBwcmlzbVZvbHVtZSgpOwogICAgICAgaWYocHJpc20gPj0gMC4wMSl7CiAgICAgICAgcHJpbnRmKCJUaGUgVm9sdW1lIG9mIFByaXNtIGlzICUwLjJmIiwgcHJpc20pOwogICAgICAgfQogICAgIH0KICAgICAgICBicmVhazsKICAgICBjYXNlIDQ6ewogICAgICAgIHByaW50ZigiUmFkaXVzIG9mIHRoZSBTcGhlcmU6Iik7CiAgICAgICAgc2NhbmYoIiVmIiwgJnJTKTsKICAgICAgICBmbG9hdCBzcGhlcmUgPSBzcGhlcmVWb2x1bWUoKTsKICAgICAgIGlmKHNwaGVyZSA+PSAwLjAxKXsKICAgICAgIHByaW50ZigiVGhlIFZvbHVtZSBvZiBTcGhlcmUgaXMgJTAuMmYiLCBzcGhlcmUpOwogICAgICAgfQogICAgIH0KICAgICAgICBicmVhazsKICAgICBjYXNlIDU6ewogICAgICAgIHByaW50ZigiQmFzZSBvZiB0aGUgUHlyYW1pZDoiKTsKICAgICAgICBzY2FuZigiJWYiLCAmYmFzZXApOwogICAgICAgIHByaW50ZigiSGVpZ2h0IG9mIHRoZSBQeXJhbWlkOiIpOwogICAgICAgIHNjYW5mKCIlZiIsICZoZWlnaHRwKTsKICAgICAgICBmbG9hdCBweXJhbWlkID0gcHlyYW1pZHZvbHVtZSgpOwogICAgICAgaWYocHlyYW1pZCA+PSAwLjAxKXsKICAgICAgIHByaW50ZigiVGhlIFZvbHVtZSBvZiBQeXJhbWlkIGlzICUwLjJmIiwgcHlyYW1pZCk7CiAgICAgICB9CiAgICAgfQogICAgIGJyZWFrOwogICAgIGNhc2UgNjp7CiAgICAgICAgcHJpbnRmKCJSYWRpdXMgb2YgdGhlIENvbmU6Iik7CiAgICAgICAgc2NhbmYoIiVmIiwgJnJDb25lKTsKICAgICAgICBwcmludGYoIkhlaWdodCBvZiB0aGUgQ29uZToiKTsKICAgICAgICBzY2FuZigiJWYiLCAmaGNvbmUpOwogICAgICAgIGZsb2F0IGNvbmUgPSBjb25lVm9sdW1lKCk7CiAgICAgICBpZihjb25lID49IDAuMDEpewogICAgICAgcHJpbnRmKCJUaGUgVm9sdW1lIG9mIENvbmUgaXMgJTAuMmYiLCBjb25lKTsKICAgICAgIH0KICAgICB9CiAgICAgICBicmVhazsKICAgICBjYXNlIDA6CiAgICAgICAgcHJpbnRmKCJFeGl0aW5nIHRoZSBwcm9ncmFtIik7CiAgICAgYnJlYWs7CiAgIH0gCiAgcmV0dXJuIDA7CiAgCn0KZmxvYXQgY3ViZVZvbHVtZSgpewogIHJldHVybiBhKmEqYTsKfQpmbG9hdCBjeWxpbmRlclZvbHVtZSgpewogIHJldHVybiBQSSpyQypyQypoOwp9CmZsb2F0IHByaXNtVm9sdW1lKCl7CiAgcmV0dXJuIGJhc2UqaGVpZ2h0Owp9CmZsb2F0IHNwaGVyZVZvbHVtZSgpewogIHJldHVybiA0LjAwLzMuMDAqUEkqclMqclMqclM7Cn0KZmxvYXQgcHlyYW1pZHZvbHVtZSgpewogIHJldHVybiAxLjAwLzMuMDAqYmFzZXAqaGVpZ2h0cDsKfQpmbG9hdCBjb25lVm9sdW1lKCl7CiAgcmV0dXJuIDEuMDAvMy4wMCpQSSpyQ29uZSpyQ29uZSpoY29uZTsKfQ==