Answer:
The area of the triangle is calculated as thus:
To calculate the perimeter of the triangle, the measurement of the slant height has to be derived;
Let s represent the slant height;
Dividing the triangle into 2 gives a right angled triangle;
The slant height, s is calculated using Pythagoras theorem as thus
The perimeter of the triangle is then calculated as thus;
For the volume of the cone,
when the triangle is spin, the base of the triangle forms the diameter of the cone;
Where
So,
So,
Base on the above illustrations, the program is as follows;
#include<iostream>
#include<cmath>
using namespace std;
void CalcArea(double b, double h)
{
//Calculate Area
double Area = 0.5 * b * h;
//Print Area
cout<<"Area = "<<Area<<endl;
}
void CalcPerimeter(double b, double h)
{
//Calculate Perimeter
double Perimeter = 2 * sqrt(pow(h,2)+pow((0.5 * b),2)) + b;
//Print Perimeter
cout<<"Perimeter = "<<Perimeter<<endl;
}
void CalcVolume(double b, double h)
{
//Calculate Volume
double Volume = (1.0/3.0) * (22.0/7.0) * pow((0.5 * b),2) * h;
//Print Volume
cout<<"Volume = "<<Volume<<endl;
}
int main()
{
double b, h;
//Prompt User for input
cout<<"Base: ";
cin>>b;
cout<<"Height: ";
cin>>h;
//Call CalcVolume function
CalcVolume(b,h);
//Call CalcArea function
CalcArea(b,h);
//Call CalcPerimeter function
CalcPerimeter(b,h);
return 0;
}