The house is built of non-standard form. All four walls are of a rectangular shape, but different height and
length. The width of the walls is two bricks. There are two types of bricks. The outer part of the wall is
constructed from the first type of brick, and the interior - from the second type. Write a program to count the
number of required bricks of each type.
class brick
{ private:
int length, width, height;// in mm
public:
void set(int len, int wid, int hei);
int getlength()
{return length;}
int getwidth()
{return width;}
int getheight()
{return height;}
};
void brick::set(int len, int wid, int hei)
{
length=len;width=wid;height=hei;
}
// calculate no of bricks required for outerwall
int outerwall(brick b, double outerwalllen, double outerwallwid, double outerwallhei)
{
return outerwalllen * 1000 / b.getlength() *
outerwallwid * 1000 / b.getwidth() *
outerwallhei * 1000 / b.getheight();
}
// calculate no of bricks required for innerwall
int innerwall(brick b, double innerwalllen, double innerwallwid, double innerwallhei)
{
return innerwalllen * 1000 / b.getlength() *
innerwalllen * 1000 / b.getwidth() *
innerwalllen * 1000 / b.getheight();
}
#include<iostream>
using namespace std;
void displaybrick(brick b)
{
cout << "Brick height: " << b.getheight() << endl;
cout << "Brick width: " << b.getwidth() << endl;
cout << "Brick length: " << b.getlength() << endl;
}
int main ()
{
brick b1;
b1.set(250,120,88);
cout<<"brick type1 length is:"<<b1.getlength()<<endl;
cout<<"brick type1 width is:"<<b1.getwidth()<<endl;
cout<<"brick type1 height is:"<<b1.getheight()<<endl;
brick b2;
b2.set(240, 115, 71);
cout<<"brick type2 length is:"<<b2.getlength()<<endl;
cout<<"brick type1 width is:"<<b2.getwidth()<<endl;
cout<<"brick type1 height is:"<<b2.getheight()<<endl;
cout << "Required I brick type: "
<< 4 * outerwall(b1, outerwalllen, outerwallwid, outerwallhei);
cout << "Required II brick type: "
<< 4 * innerwall(b2, innerwallen, innerwallwid, innerwallhei) << endl;
return(0);
}
I am new in C++ but I made this code with the help of examples i did. I just want to ask that as the dimensions of wall is not given then how to make the code. Do I need to define a variable for this? Please help me as I am a daily and serious learner of C++.At last I just called the function outerwall and innerwall but I do not know what to do with wall dimensions.