# Find the surface area of pentagonal prism

A pentagonal prism is a three-dimensional geometric shape that consists of two parallel pentagonal bases connected by rectangular sides. Finding the surface area of a pentagonal prism involves calculating the total area of all its external faces. This calculation is useful in various applications such as architecture, engineering, and design, where prism-like structures are common.

## Problem Statement

Given the apothem (distance from the center of a regular polygon to its midpoint), base length of the pentagon, and the height of the prism, the task is to calculate the surface area of the pentagonal prism. The formula for finding the surface area of a pentagonal prism is:

Surface Area = 5 * apothem * base + 5 * base * height

## Example Scenario

Imagine you are an interior designer working on a project that involves creating a decorative column in the shape of a pentagonal prism. You need to determine the total surface area of the prism to estimate the amount of material needed to cover it. This calculation helps you plan the design and material requirements accurately.

## Idea to Solve the Problem

To solve this problem, we can follow these steps:

1. Accept the apothem, base length, and height of the pentagonal prism as inputs.
2. Use the formula to calculate the surface area of the pentagonal prism.
3. Display the calculated surface area.

## Pseudocode

``````function surface_area(apothem, base, height):
area = 5 * apothem * base + 5 * base * height
return area

main:
apothem1 = 4
base1 = 7
height1 = 5

apothem2 = 3.5
base2 = 6
height2 = 4

area1 = surface_area(apothem1, base1, height1)
area2 = surface_area(apothem2, base2, height2)

print("Pentagonal Surface [ apothem :", apothem1, ", base :", base1, ", height :", height1, "]")
print("Area :", area1)

print("Pentagonal Surface [ apothem :", apothem2, ", base :", base2, ", height :", height2, "]")
print("Area :", area2)``````

## Algorithm Explanation

1. Define a function `surface_area` that takes the apothem, base length, and height as inputs.
2. Inside the function, use the provided formula to calculate the surface area of the pentagonal prism.
3. In the `main` function, set two test cases with different values for apothem, base, and height.
4. Calculate the surface areas for each test case by calling the `surface_area` function.
5. Display the calculated surface areas along with their respective apothem, base, and height values.

## Code Solution

``````//C Program
//Find the surface area of pentagonal prism
#include <stdio.h>

#include <math.h>

void surface_area(double apothem, double base, double height)
{
//Calculate Formula
// 5 * apothem * base + 5 * base * height
double area = 5 * apothem * base + 5 * base * height;
//Here
// apothem : line segment from the center to the midpoint
// base : base of pentagonal
// height : height of pentagonal
//Display the result of surface area
printf(" Pentagonal Surface [ apothem : %lf, base : %lf, height : %lf ] ", apothem, base, height);
printf("\n Area : %lf\n\n", area);
}
int main()
{
//Test Case
surface_area(4, 7, 5);
surface_area(3.5, 6, 4);
return 0;
}``````

#### Output

`````` Pentagonal Surface [ apothem : 4.000000, base : 7.000000, height : 5.000000 ]
Area : 315.000000

Pentagonal Surface [ apothem : 3.500000, base : 6.000000, height : 4.000000 ]
Area : 225.000000
``````
``````// Java Program
// Find the surface area of pentagonal prism
class Pentagonal
{
//Calculate surface area of pentagonal prism by given apothem, base and height
public void surface_area(double apothem, double base, double height)
{
//Calculate Formula
// 5 * apothem * base + 5 * base * height
double area = 5 * apothem * base + 5 * base * height;
//Here
// apothem : line segment from the center to the midpoint
// base : base of pentagonal
// height : height of pentagonal
//Display the result of surface area
System.out.print(" Pentagonal Surface [ apothem : "+apothem+", base : "+base+", height : "+height+" ] " );
System.out.print("\n Area : "+area+"\n\n" );
}
public static void main(String[] args) {

Pentagonal obj = new Pentagonal();
//Test Cases
obj.surface_area(4,7,5);
obj.surface_area(3.5,6,4);
}
}``````

#### Output

`````` Pentagonal Surface [ apothem : 4.0, base : 7.0, height : 5.0 ]
Area : 315.0

Pentagonal Surface [ apothem : 3.5, base : 6.0, height : 4.0 ]
Area : 225.0
``````
``````// C++ Program
// Find the surface area of pentagonal prism
#include<iostream>

using namespace std;
class Pentagonal
{
public:
//Calculate surface area of pentagonal prism by given apothem, base and height
void surface_area(double apothem, double base, double height)
{
//Calculate Formula
// 5 *apothem *base + 5 *base *height
double area = 5 *apothem *base + 5 *base *height;
cout << " Pentagonal Surface [ apothem : " << apothem << ", base : " << base << ", height : " << height << " ] ";
cout << "\n Area : " << area << "\n\n";
}
};
int main()
{
Pentagonal obj =  Pentagonal();
//Test Cases
obj.surface_area(4, 7, 5);
obj.surface_area(3.5, 6, 4);
return 0;
}``````

#### Output

`````` Pentagonal Surface [ apothem : 4, base : 7, height : 5 ]
Area : 315

Pentagonal Surface [ apothem : 3.5, base : 6, height : 4 ]
Area : 225
``````
``````// C# Program
// Find the surface area of pentagonal prism
using System;
class Pentagonal
{
//Calculate surface area of pentagonal prism by given apothem, base and height
public void surface_area(double apothem, double base_side, double height)
{
//Calculate Formula
// 5 * apothem * base + 5 * base * height
double area = 5 * apothem * base_side + 5 * base_side * height;
Console.Write(" Pentagonal Surface [ apothem : " + apothem + ", base : " + base_side + ", height : " + height + " ] ");
Console.Write("\n Area : " + area + "\n\n");
}
public static void Main(String[] args)
{
Pentagonal obj = new Pentagonal();
//Test Cases
obj.surface_area(4, 7, 5);
obj.surface_area(3.5, 6, 4);
}
}``````

#### Output

`````` Pentagonal Surface [ apothem : 4, base : 7, height : 5 ]
Area : 315

Pentagonal Surface [ apothem : 3.5, base : 6, height : 4 ]
Area : 225
``````
``````<?php
// Php Program
// Find the surface area of pentagonal prism
class Pentagonal
{
//Calculate surface area of pentagonal prism by given apothem, base and height
public 	function surface_area(\$apothem, \$base, \$height)
{
//Calculate Formula
// 5 *apothem *base + 5 *base *height
\$area = 5 *\$apothem *\$base + 5 *\$base *\$height;
//Here
// apothem : line segment from the center to the midpoint
// base : base of pentagonal
// height : height of pentagonal
//Display the result of surface area
echo(" Pentagonal Surface [ apothem : ". \$apothem .", base : ". \$base .", height : ". \$height ." ] ");
echo("\n Area : ". \$area ."\n\n");
}
}

function main()
{
\$obj = new Pentagonal();
//Test Cases
\$obj->surface_area(4, 7, 5);
\$obj->surface_area(3.5, 6, 4);
}
main();``````

#### Output

`````` Pentagonal Surface [ apothem : 4, base : 7, height : 5 ]
Area : 315

Pentagonal Surface [ apothem : 3.5, base : 6, height : 4 ]
Area : 225
``````
``````// Node Js Program
// Find the surface area of pentagonal prism
class Pentagonal
{
//Calculate surface area of pentagonal prism by given apothem, base and height
surface_area(apothem, base, height)
{
//Calculate Formula
// 5 *apothem *base + 5 *base *height
var area = 5 *apothem *base + 5 *base *height;
//Here
// apothem : line segment from the center to the midpoint
// base : base of pentagonal
// height : height of pentagonal
//Display the result of surface area
process.stdout.write(" Pentagonal Surface [ apothem : " + apothem + ", base : " + base + ", height : " + height + " ] ");
process.stdout.write("\n Area : " + area + "\n\n");
}
}

function main(args)
{
var obj = new Pentagonal();
//Test Cases
obj.surface_area(4, 7, 5);
obj.surface_area(3.5, 6, 4);
}
main();``````

#### Output

`````` Pentagonal Surface [ apothem : 4, base : 7, height : 5 ]
Area : 315

Pentagonal Surface [ apothem : 3.5, base : 6, height : 4 ]
Area : 225
``````
``````#  Python 3 Program
#  Find the surface area of pentagonal prism
class Pentagonal :
# Calculate surface area of pentagonal prism by given apothem, base and height
def surface_area(self, apothem, base, height) :
# Calculate Formula
#  5 * apothem * base + 5 * base * height
area = 5 * apothem * base + 5 * base * height
# Here
#  apothem : line segment from the center to the midpoint
#  base : base of pentagonal
#  height : height of pentagonal
# Display the result of surface area
print(" Pentagonal Surface [ apothem : ", apothem ,", base : ", base ,", height : ", height ," ] ", end = "")
print("\n Area : ", area ,"\n\n", end = "")

def main() :
obj = Pentagonal()
# Test Cases
obj.surface_area(4, 7, 5)
obj.surface_area(3.5, 6, 4)

if __name__ == "__main__": main()``````

#### Output

`````` Pentagonal Surface [ apothem :  4 , base :  7 , height :  5  ]
Area :  315

Pentagonal Surface [ apothem :  3.5 , base :  6 , height :  4  ]
Area :  225.0
``````
``````#  Ruby Program
#  Find the surface area of pentagonal prism
class Pentagonal

# Calculate surface area of pentagonal prism by given apothem, base and height
def surface_area(apothem, base, height)

# Calculate Formula
#  5 * apothem * base + 5 * base * height
area = 5 * apothem * base + 5 * base * height
# Here
#  apothem  :line segment from the center to the midpoint
#  base  :base of pentagonal
#  height  :height of pentagonal
# Display the result of surface area
print(" Pentagonal Surface [ apothem  :", apothem ,", base  :", base ,", height  :", height ," ] ")
print("\n Area  :", area ,"\n\n")
end
end
def main()

obj = Pentagonal.new()
# Test Cases
obj.surface_area(4, 7, 5)
obj.surface_area(3.5, 6, 4)
end
main()``````

#### Output

`````` Pentagonal Surface [ apothem  :4, base  :7, height  :5 ]
Area  :315

Pentagonal Surface [ apothem  :3.5, base  :6, height  :4 ]
Area  :225.0

``````
``````// Scala Program
// Find the surface area of pentagonal prism
class Pentagonal
{
//Calculate surface area of pentagonal prism by given apothem, base and height
def surface_area(apothem: Double, base: Double, height: Double): Unit = {
//Calculate Formula
// 5 * apothem * base + 5 * base * height
var area: Double = 5 * apothem * base + 5 * base * height;
//Here
// apothem : line segment from the center to the midpoint
// base : base of pentagonal
// height : height of pentagonal
//Display the result of surface area
print(" Pentagonal Surface [ apothem : " + apothem + ", base : " + base + ", height : " + height + " ] ");
print("\n Area : " + area + "\n\n");
}
}
object Main
{
def main(args: Array[String]): Unit = {
var obj: Pentagonal = new Pentagonal();
//Test Cases
obj.surface_area(4, 7, 5);
obj.surface_area(3.5, 6, 4);
}
}``````

#### Output

`````` Pentagonal Surface [ apothem : 4.0, base : 7.0, height : 5.0 ]
Area : 315.0

Pentagonal Surface [ apothem : 3.5, base : 6.0, height : 4.0 ]
Area : 225.0
``````
``````// Swift Program
// Find the surface area of pentagonal prism
class Pentagonal
{
//Calculate surface area of pentagonal prism by given apothem, base and height
func surface_area(_ apothem: Double, _ base: Double, _ height: Double)
{
//Calculate Formula
// 5 * apothem * base + 5 * base * height
let area: Double = 5 * apothem * base + 5 * base * height;
//Here
// apothem : line segment from the center to the midpoint
// base : base of pentagonal
// height : height of pentagonal
//Display the result of surface area
print(" Pentagonal Surface [ apothem : ", apothem ,", base : ", base ,", height : ", height ," ] ", terminator: "");
print("\n Area : ", area ,"\n\n", terminator: "");
}
}
func main()
{
let obj: Pentagonal = Pentagonal();
//Test Cases
obj.surface_area(4, 7, 5);
obj.surface_area(3.5, 6, 4);
}
main();``````

#### Output

`````` Pentagonal Surface [ apothem :  4.0 , base :  7.0 , height :  5.0  ]
Area :  315.0

Pentagonal Surface [ apothem :  3.5 , base :  6.0 , height :  4.0  ]
Area :  225.0
``````

## Output Explanation

The code calculates the surface area for each test case and displays the results. For a pentagonal prism with an apothem of 4, base length of 7, and height of 5, the surface area is 315. Similarly, for an apothem of 3.5, base length of 6, and height of 4, the surface area is 225.

## Time Complexity

The time complexity of this code is constant O(1) because the calculations involve basic arithmetic operations, which take a constant amount of time regardless of the input size. The program performs a fixed number of operations for each test case, making it efficient.

## Comment

Please share your knowledge to improve code and content standard. Also submit your doubts, and test case. We improve by your feedback. We will try to resolve your query as soon as possible.