Find the surface area of pentagonal prism
Here given code implementation process.
//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
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.
New Comment