当前位置: 首页>>代码示例>>C++>>正文


C++ Polyhedron::setSide1方法代码示例

本文整理汇总了C++中Polyhedron::setSide1方法的典型用法代码示例。如果您正苦于以下问题:C++ Polyhedron::setSide1方法的具体用法?C++ Polyhedron::setSide1怎么用?C++ Polyhedron::setSide1使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Polyhedron的用法示例。


在下文中一共展示了Polyhedron::setSide1方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

int main()
{
	Polyhedron polyhedron; // new polyhedron object
	float side;
	float height;

	// Q5 : 10 points
	// Convert all C input/output (printf/scanf) to C++ input/output (cin/cout) in this main method.
	// (this includes the 3 C output (printf) used near the end of the main method.)
	// Your C++ input/output must be equivalent to the given C input/output.

	cout << "Enter the sides of the base of the polhedron:" << endl;
	cout << "If the polhedron is triangular, please enter 0 for any given side." << endl;

	cout << "Side 1: ";
	cin >> side;
	polyhedron.setSide1(side);
	cout << endl;

	cout << "Side 2: ";
	cin >> side;
	polyhedron.setSide2(side);
	cout << endl;

	cout << "Side 3: ";
	cin >> side;
	polyhedron.setSide3(side);
	cout << endl;

	cout << "Side 4: ";
	cin >> side;
	polyhedron.setSide4(side);
	cout << endl;

	cout << "Height: ";
	cin >> height;
	polyhedron.setHeight(height);
	cout << endl;

	Shape temp = polyhedron.TypeChecker();
	string shape;

	switch (temp)
	{
	case Triangular:
		shape = "Triangular Polyhedron";
		break;
	case Square:
		shape = "Square Polyhedron";
		break;
	default:
		shape = "Rectangular Polyhedron";
		break;
	}

	float baseArea = polyhedron.BaseArea();
	float pyramidVolume = polyhedron.PyramidVolume(baseArea);
	float prismVolume = polyhedron.PrismVolume(baseArea);

	cout << "This is a " << shape << "." << endl;
	cout << "The volume of this pyramid is: " << pyramidVolume << endl;
	cout << "The volume of this prism is: " << prismVolume << endl;

	return 0;
}
开发者ID:bettyjing,项目名称:CSE240,代码行数:65,代码来源:HW8.cpp


注:本文中的Polyhedron::setSide1方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。