#include<iostream>
using namespace std;
class Rectangle
{
private:
int height,weight ;
public:
void getValue(int ,int );
int area()
{
return height*weight;
}
};
void Rectangle::getValue(int a,int b)
{
height=a;
weight=b;
}
class Cost
{
private:
int tk;
public:
void getvalue(int c)
{
tk=c;
}
int totalCost(Rectangle A)
{
return tk*A.area();
}
};
int main()
{
int a,b;
cin>>a>>b;
Rectangle rct;
rct.getValue(a,b);
cout<< "Total area = "<<rct.area()<<endl;
int i;
Cost cst;
cout<<"enter cost per meter:"<<endl;
cin>>i;
cst.getvalue(i);
cout<<"Total cost :"<<endl;
cout<<cst.totalCost(rct);
return 0;
}
using namespace std;
class Rectangle
{
private:
int height,weight ;
public:
void getValue(int ,int );
int area()
{
return height*weight;
}
};
void Rectangle::getValue(int a,int b)
{
height=a;
weight=b;
}
class Cost
{
private:
int tk;
public:
void getvalue(int c)
{
tk=c;
}
int totalCost(Rectangle A)
{
return tk*A.area();
}
};
int main()
{
int a,b;
cin>>a>>b;
Rectangle rct;
rct.getValue(a,b);
cout<< "Total area = "<<rct.area()<<endl;
int i;
Cost cst;
cout<<"enter cost per meter:"<<endl;
cin>>i;
cst.getvalue(i);
cout<<"Total cost :"<<endl;
cout<<cst.totalCost(rct);
return 0;
}
Quote: