第五周任务三

#include <iostream>
#include <cmath>

using namespace std;
class Box
{
public:
	void volume();
	void area();
	void set();
	Box (int h = 18,int w = 20,int len = 36):height(h),width(w),length(len){}
private:
	double length;
	double width;
	double height;
};
int main()
{
	Box a[5] = {

	Box(10,12,15),
	Box(15,18,20),
	Box(16,20,26),
	};

	a[4].set();

	cout << "the volume of a[0] is: " << endl;
	a[0].volume();
	cout << "the area of a[0] is: " <<  endl;
	a[0].area();

	cout << "the volume of a[0] is: " << endl;
	a[1].volume();
	cout << "the area of a[0] is: " << endl;
	a[1].area();

	cout << "the volume of a[0] is: " << endl;
	a[2].volume(); 
	cout << "the area of a[0] is: " << endl;
	a[2].area();

	cout << "the volume of a[0] is: " << endl;
	a[3].volume();
	cout << "the area of a[0] is: " << endl;
	a[3].area();

    cout << "the volume of a[4] is: " << endl;
	a[4].volume();
	cout << "the area of a[4] is: " << endl;
	a[4].area();

	system("pause");

	return 0;
}

void Box::area()
{
	double ar;

    ar=2*(length * height + length * width + height * width);

	cout << ar << endl;

}

void Box::volume()
{
	double vol;

	vol = height * width * length;

	cout << vol << endl;
}

void Box::set()
{
	cin >> height >> length >> width;
}

阅读更多
文章标签: 任务 include system
上一篇第五周任务二
下一篇第六周任务三
想对作者说点什么? 我来说一句

没有更多推荐了,返回首页

关闭
关闭