Beispiel #1
0
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;
}