Now I have created the second version of my studding program. There is new features here you could calculate and surface of the cylinder and parallelipiped. Please don't try the 3 and 4 functions - they don't work.
#include
#include
using namespace std;
const float PI = 3.1415926;
int main()
{
cout <<"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD\n"
<<"D This program calculate the surface D\n"
<<"D and the volume of the different objects D\n"
<<"D If you want to close this application type D\n"
<<"D D\n"
<<"D Ctrl+C D\n"
<<"DDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDDD\n"
<int choice;
cout<<"Enter the number of your choice: \n";
cout<<"1 - Surface and volume of cylinder.\n";
cout<<"2 - Surface and volume of parallelipiped.\n";
cout<<"3 - Surface and volume of sphere.\n";
cout<<"4 - Surface and volume of pyramid.\n ";
cout<cout<<"Please enter the desired number: ";
cin>>choice;
switch (choice)
{
case 1:
cout<<"\nYou decide to calculate the surface and volume of cylinder.\n"<for(;;)
{
float diam;
float surf;
float high;
float volume;
cout<<"Enter the diameter in meters: ";
cin>>diam;
float radius;
radius=diam/2;
while (diam<0 || diam==0)
{
cout << "Error!\n";
system("exit");
return 0;
}
cout<<"Enter the high of the cilinder in meters: ";
cin>>high;
while (high<0 || high==0)
{
cout << "Error!\n";
system("exit");
return 0;
}
surf=(2*PI*radius*radius)+(2*PI*radius*high);
cout<<" \n";
cout<<" The surface is: "<cout<<" \n"
<volume=surf*high;
cout<<" The volume is "<cout<<" \n"
<cout<<"If you want to exit just press Ctrl+C\n"< cout<<"---------------------------------------"< }
case 2:;
cout<<"\nYou decide to calculate the surface and volume of parallelipiped.\n"<for (;;)
{
/*At first we must find the surface which is S=2(a*b)+2(a*c)+2(b*c)
and declare the variable*/
float A;
float B;
float C;
float surf_p;
float volume_p;
/* If the entered value is negative the program will exit immediatly*/
cout<<"Enter the size of A in meters: ";
cin >> A;
while (A<0 || A==0)
{
cout << "Error!\n";
system("exit");
return 0;
}
cout<<"Enter the size of B in meters: ";
cin >> B;
while (B<0 || B==0)
{
cout << "Error!\n";
system("exit");
return 0;
}
cout<<"Enter the size of C in meters: ";
cin >> C;
while (C<0 || C==0)
{
cout << "Error!\n";
system("exit");
return 0;
}
surf_p=(2*A*C)+(2*A*B)+(2*B*C);
cout<<" \n";
cout<<" The surface is: "<cout<<" \n"
<volume_p=A*B*C;
cout<<" The volume is "<cout<<" \n"
<cout<<"If you want to exit just press Ctrl+C\n"< cout<<"---------------------------------------"< }
}
// system("PAUSE"); return 0;
}