Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- class Cuboid{
- private:
- float a;
- float b;
- float h;
- public:
- Cuboid(float x,float y,float z){
- a=x;
- b=y;
- h=z;
- }
- void set_a(float x){
- a=x;
- }
- float get_a(){
- return a;
- }
- void set_b(float x){
- b=x;
- }
- float get_b(){
- return b;
- }
- void set_h(float x){
- h=x;
- }
- float get_h(){
- return h;
- }
- float P(){
- return 2*(a+b+h);
- }
- float V(){
- return a*b*h;
- }
- };
- int main()
- {
- float a,b,h;
- cin>> a >> b >> h;
- Cuboid object(a,b,h);
- cout<< object.P() << endl;
- cout<< object.V() << endl;
- return 0;
- }
- #include <iostream>
- using namespace std;
- class Cuboid
- {
- private:
- int a,b,c;
- public:
- Cuboid(int a=0,int b=0,int c=0)
- {
- this->a=a;
- this->b=b;
- this->c=c;
- }
- int area()
- {
- return 2*(a+b+c);
- }
- int volume()
- {
- return a*b*c;
- }
- };
- int main()
- {
- int a,b,c;
- cin>>a>>b>>c;
- Cuboid cub(a,b,c);
- cout<<"The area of the Cuboid is: "<<cub.area()<<"\nIt's volume is: "<<cub.volume()<<endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement