Computer Science, asked by ganeshraj70, 5 hours ago

Create a program that calculates the cost of construction for building a house for this. Derive a class publicly from three base classes cement, steel and wood. The requirements for building a house will be 500 bags of cement where each bags costs rs150, three tons of steel costing rs 28000 per ton and so on cubic feet of wood costing rs 1500 per cubic foot.

please ans ​

Answers

Answered by dreamrob
4

Program in C++:

#include<iostream>

using namespace std;

class cement

{

protected:

 int cement_cost;

 cement()

 {

  cement_cost = 500 * 150;  

 }

};

class steel

{

protected:

 int steel_cost;

 steel()

 {

  steel_cost = 3 * 28000;

 }

};

class wood

{

protected:

 int wood_cost;

 wood()

 {

  wood_cost = 1 * 1500;

 }

};

class cost : public cement , public steel , public wood

{

public:

 int total_cost;

 cost()

 {

  total_cost = cement_cost + steel_cost + wood_cost;

 }

};

int main()

{

cost c;

cout<<"The cost of construction for building a house = "<<c.total_cost;

return 0;

}

Output:

The cost of construction for building a house = 160500

Similar questions