Answer to Question #327317 in C++ for Programer Training

Question #327317

Define a function CalcPyramidVolume with double data type parameters baseLength, baseWidth, and pyramidHeight, that returns as a double the volume of a pyramid with a rectangular base. Relevant geometry equations: 

Volume = base area x height x 1/3 

Base area = base length x base width. 

(Watch out for integer division).


1
Expert's answer
2022-04-11T13:18:28-0400
#include<iostream>

using namespace std;

double CalcPyramidVolume(double baseLength, double baseWidth, double pyramidHeight)
{
	double BaseArea = baseLength * baseWidth;
	double Volume = BaseArea*pyramidHeight/ 3;
	return Volume;
}

int main()
{
	double baseLength, baseWidth, pyramidHeight;
	cout << "Please, enter a baseLength of piramid: ";
	cin >> baseLength;
	cout << "Please, enter a baseWidth of piramid: ";
	cin >> baseWidth;
	cout << "Please, enter a pyramidHeight of piramid: ";
	cin >> pyramidHeight;
	cout << "The Volume pf piaramid is " << CalcPyramidVolume(baseLength, baseWidth,pyramidHeight);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS