# Find the surface area of Hexagonal Prism

Here given code implementation process.

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

#include <math.h>

//Calculate surface area of hexagonal prism by given base and height
void hexagonal_surface(double base, double height)
{
// Formula
// 6ah + 3√3a²
// Here a is base and h is height
double area = 6 * base * height + 3 * sqrt(3) * base * base;;
//Display result
printf(" Hexagonal Prism Size [ base : %lf, height : %lf] ", base, height);
printf("\n Surface area : %lf\n\n", area);
}
int main()
{
//Test Case
hexagonal_surface(7, 8);
hexagonal_surface(5, 5);
hexagonal_surface(6, 5.8);
return 0;
}``````

#### Output

`````` Hexagonal Prism Size [ base : 7.000000, height : 8.000000]
Surface area : 590.611469

Hexagonal Prism Size [ base : 5.000000, height : 5.000000]
Surface area : 279.903811

Hexagonal Prism Size [ base : 6.000000, height : 5.800000]
Surface area : 395.861487
``````
``````// Java Program
// Find the surface area of Hexagonal Prism
class Hexagonal
{
//Calculate surface area of hexagonal prism by given base and height
public void hexagonal_surface(double base, double height)
{
// Formula
// 6ah + 3√3a²
// Here a is base and h is height
double area = 6 * base * height + 3 * Math.sqrt(3) * base * base;;
//Display result
System.out.print(" Hexagonal Prism Size [ base : " + base + ", height : " + height + "] ");
System.out.print("\n Surface area : " + area + "\n\n");
}
public static void main(String[] args)
{
Hexagonal obj = new Hexagonal();
//Test Case
obj.hexagonal_surface(7, 8);
obj.hexagonal_surface(5, 5);
obj.hexagonal_surface(6, 5.8);
}
}``````

#### Output

`````` Hexagonal Prism Size [ base : 7.0, height : 8.0]
Surface area : 590.611468712625

Hexagonal Prism Size [ base : 5.0, height : 5.0]
Surface area : 279.9038105676658

Hexagonal Prism Size [ base : 6.0, height : 5.8]
Surface area : 395.8614872174387
``````
``````// C++ Program
// Find the surface area of Hexagonal Prism
#include<iostream>
#include <math.h>
using namespace std;
class Hexagonal
{
public:
//Calculate surface area of hexagonal prism by given base and height
void hexagonal_surface(double base, double height)
{
// Formula
// 6ah + 3√3a²
// Here a is base and h is height
double area = 6 *base * height + 3 * sqrt(3) * base * base;;
cout << " Hexagonal Prism Size [ base : " << base << ", height : " << height << "] ";
cout << "\n Surface area : " << area << "\n\n";
}
};
int main()
{
Hexagonal obj;
//Test Case
obj.hexagonal_surface(7, 8);
obj.hexagonal_surface(5, 5);
obj.hexagonal_surface(6, 5.8);
return 0;
}``````

#### Output

`````` Hexagonal Prism Size [ base : 7, height : 8]
Surface area : 590.611

Hexagonal Prism Size [ base : 5, height : 5]
Surface area : 279.904

Hexagonal Prism Size [ base : 6, height : 5.8]
Surface area : 395.861
``````
``````// C# Program
// Find the surface area of Hexagonal Prism
using System;
class Hexagonal
{
//Calculate surface area of hexagonal prism by given base and height
public void hexagonal_surface(double base_size, double height)
{
// Formula
// 6ah + 3√3a²
// Here a is base and h is height
double area = 6 * base_size * height + 3 * Math.Sqrt(3) * base_size * base_size;;
Console.Write(" Hexagonal Prism Size [ base : " + base_size + ", height : " + height + "] ");
Console.Write("\n Surface area : " + area + "\n\n");
}
public static void Main(String[] args)
{
Hexagonal obj = new Hexagonal();
//Test Case
obj.hexagonal_surface(7, 8);
obj.hexagonal_surface(5, 5);
obj.hexagonal_surface(6, 5.8);
}
}``````

#### Output

`````` Hexagonal Prism Size [ base : 7, height : 8]
Surface area : 590.611468712625

Hexagonal Prism Size [ base : 5, height : 5]
Surface area : 279.903810567666

Hexagonal Prism Size [ base : 6, height : 5.8]
Surface area : 395.861487217439
``````
``````<?php
// Php Program
// Find the surface area of Hexagonal Prism
class Hexagonal
{
//Calculate surface area of hexagonal prism by given base and height
public 	function hexagonal_surface(\$base, \$height)
{
// Formula
// 6ah + 3√3a²
// Here a is base and h is height
\$area = 6 * \$base * \$height + 3 * sqrt(3) * \$base * \$base;;
//Display result
echo(" Hexagonal Prism Size [ base : ". \$base .", height : ". \$height ."] ");
echo("\n Surface area : ". \$area ."\n\n");
}
}

function main()
{
\$obj = new Hexagonal();
//Test Case
\$obj->hexagonal_surface(7, 8);
\$obj->hexagonal_surface(5, 5);
\$obj->hexagonal_surface(6, 5.8);
}
main();``````

#### Output

`````` Hexagonal Prism Size [ base : 7, height : 8]
Surface area : 590.61146871262

Hexagonal Prism Size [ base : 5, height : 5]
Surface area : 279.90381056767

Hexagonal Prism Size [ base : 6, height : 5.8]
Surface area : 395.86148721744
``````
``````// Node Js Program
// Find the surface area of Hexagonal Prism
class Hexagonal
{
//Calculate surface area of hexagonal prism by given base and height
hexagonal_surface(base, height)
{
// Formula
// 6ah + 3√3a²
// Here a is base and h is height
var area = 6 *base *height + 3 *Math.sqrt(3) *base *base;;
//Display result
process.stdout.write(" Hexagonal Prism Size [ base : " + base + ", height : " + height + "] ");
process.stdout.write("\n Surface area : " + area + "\n\n");
}
}

function main(args)
{
var obj = new Hexagonal();
//Test Case
obj.hexagonal_surface(7, 8);
obj.hexagonal_surface(5, 5);
obj.hexagonal_surface(6, 5.8);
}
main();``````

#### Output

`````` Hexagonal Prism Size [ base : 7, height : 8]
Surface area : 590.611468712625

Hexagonal Prism Size [ base : 5, height : 5]
Surface area : 279.9038105676658

Hexagonal Prism Size [ base : 6, height : 5.8]
Surface area : 395.8614872174387
``````
``````#  Python 3 Program
#  Find the surface area of Hexagonal Prism
import math
class Hexagonal :
# Calculate surface area of hexagonal prism by given base and height
def hexagonal_surface(self, base, height) :
#  Formula
#  6ah + 3√3a²
#  Here a is base and h is height
area = 6 * base * height + 3 * math.sqrt(3) * base * base
# Display result
print(" Hexagonal Prism Size [ base : ", base ,", height : ", height ,"] ", end = "")
print("\n Surface area : ", area ,"\n\n", end = "")

def main() :
obj = Hexagonal()
# Test Case
obj.hexagonal_surface(7, 8)
obj.hexagonal_surface(5, 5)
obj.hexagonal_surface(6, 5.8)

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

#### Output

`````` Hexagonal Prism Size [ base :  7 , height :  8 ]
Surface area :  590.611468712625

Hexagonal Prism Size [ base :  5 , height :  5 ]
Surface area :  279.9038105676658

Hexagonal Prism Size [ base :  6 , height :  5.8 ]
Surface area :  395.8614872174387
``````
``````#  Ruby Program
#  Find the surface area of Hexagonal Prism
class Hexagonal

# Calculate surface area of hexagonal prism by given base and height
def hexagonal_surface(base, height)

#  Formula
#  6ah + 3√3a²
#  Here a is base and h is height
area = 6 * base * height + 3 * Math.sqrt(3) * base * base
# Display result
print(" Hexagonal Prism Size [ base  : ", base ,", height  : ", height ,"] ")
print("\n Surface area  : ", area ,"\n\n")
end
end
def main()

obj = Hexagonal.new()
# Test Case
obj.hexagonal_surface(7, 8)
obj.hexagonal_surface(5, 5)
obj.hexagonal_surface(6, 5.8)
end
main()``````

#### Output

`````` Hexagonal Prism Size [ base  : 7, height  : 8]
Surface area  : 590.611468712625

Hexagonal Prism Size [ base  : 5, height  : 5]
Surface area  : 279.9038105676658

Hexagonal Prism Size [ base  : 6, height  : 5.8]
Surface area  : 395.8614872174387

``````
``````// Scala Program
// Find the surface area of Hexagonal Prism
class Hexagonal
{
//Calculate surface area of hexagonal prism by given base and height
def hexagonal_surface(base: Double, height: Double): Unit = {
// Formula
// 6ah + 3√3a²
// Here a is base and h is height
var area: Double = 6 * base * height + 3 * Math.sqrt(3) * base * base;
//Display result
print(" Hexagonal Prism Size [ base : " + base + ", height : " + height + "] ");
print("\n Surface area : " + area + "\n\n");
}
}
object Main
{
def main(args: Array[String]): Unit = {
var obj: Hexagonal = new Hexagonal();
//Test Case
obj.hexagonal_surface(7, 8);
obj.hexagonal_surface(5, 5);
obj.hexagonal_surface(6, 5.8);
}
}``````

#### Output

`````` Hexagonal Prism Size [ base : 7.0, height : 8.0]
Surface area : 590.611468712625

Hexagonal Prism Size [ base : 5.0, height : 5.0]
Surface area : 279.9038105676658

Hexagonal Prism Size [ base : 6.0, height : 5.8]
Surface area : 395.8614872174387
``````
``````// Swift Program
// Find the surface area of Hexagonal Prism
import Foundation
class Hexagonal
{
//Calculate surface area of hexagonal prism by given base and height
func hexagonal_surface(_ base: Double, _ height: Double)
{
// Formula
// 6ah + 3√3a²
// Here a is base and h is height
let area: Double = 6 * base * height + 3 * sqrt(3) * base * base;
//Display result
print(" Hexagonal Prism Size [ base : ", base ,", height : ", height ,"] ", terminator: "");
print("\n Surface area : ", area ,"\n\n", terminator: "");
}
}
func main()
{
let obj: Hexagonal = Hexagonal();
//Test Case
obj.hexagonal_surface(7, 8);
obj.hexagonal_surface(5, 5);
obj.hexagonal_surface(6, 5.8);
}
main();``````

#### Output

`````` Hexagonal Prism Size [ base :  7.0 , height :  8.0 ]
Surface area :  590.611468712625

Hexagonal Prism Size [ base :  5.0 , height :  5.0 ]
Surface area :  279.903810567666

Hexagonal Prism Size [ base :  6.0 , height :  5.8 ]
Surface area :  395.861487217439
``````

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 