Find surface area of dodecahedron

Here given code implementation process.

/*
  C Program 
  Find surface area of dodecahedron
*/
#include <stdio.h>

#include <math.h>

//Calculate surface area of dodecahedron by side
void surface_area(double side)
{
  // Formula of dodecahedron surface area 
  // 3 √(25 + 10 √(5)) a²
  // here a is side
  printf("\nGiven Side : %lf", side);
  //Calculate surface of dodecahedron
  double area = ((3 * sqrt(25 + 10 * (sqrt(5)))) * (side * side));
  printf("\nSurface area of dodecahedron : %lf\n", area);
}
int main()
{
  //Simple Case
  surface_area(7);
  surface_area(4);
  surface_area(6.2);
  return 0;
}

Output

Given Side : 7.000000
Surface area of dodecahedron : 1011.640712

Given Side : 4.000000
Surface area of dodecahedron : 330.331661

Given Side : 6.200000
Surface area of dodecahedron : 793.621815
// Java Program
// Find surface area of dodecahedron
class Dodecahedron
{
  //Calculate surface area of dodecahedron by side
  public void surface_area(double side)
  {
    // Formula of dodecahedron surface area 
    // 3 √(25 + 10 √(5)) a²
    // here a is side
    System.out.print("\nGiven Side : " + side);
    //Calculate surface of dodecahedron
    double area = ((3 * Math.sqrt(25 + 10 * (Math.sqrt(5)))) * (Math.pow(side, 2)));
    System.out.print("\nSurface area of dodecahedron : " + area + "\n");
  }
  public static void main(String[] args)
  {
    Dodecahedron obj = new Dodecahedron();
    //Simple Case
    obj.surface_area(7);
    obj.surface_area(4);
    obj.surface_area(6.2);
  }
}

Output

Given Side : 7.0
Surface area of dodecahedron : 1011.6407115463126

Given Side : 4.0
Surface area of dodecahedron : 330.33166091308163

Given Side : 6.2
Surface area of dodecahedron : 793.6218153436787
// C++ Program
// Find surface area of dodecahedron
#include<iostream>
#include<math.h>
using namespace std;
class Dodecahedron
{
  public:
    //Calculate surface area of dodecahedron by side
    void surface_area(double side)
    {
      cout << "\nGiven Side : " << side;
      //Calculate surface of dodecahedron
      double area = ((3 * sqrt(25 + 10 * (sqrt(5)))) * (side * side));
      cout << "\nSurface area of dodecahedron : " << area << "\n";
    }
};
int main()
{
  Dodecahedron obj ;
  //Simple Case
  obj.surface_area(7);
  obj.surface_area(4);
  obj.surface_area(6.2);
  return 0;
}

Output

Given Side : 7
Surface area of dodecahedron : 1011.64

Given Side : 4
Surface area of dodecahedron : 330.332

Given Side : 6.2
Surface area of dodecahedron : 793.622
// C# Program
// Find surface area of dodecahedron
using System;
class Dodecahedron
{
  //Calculate surface area of dodecahedron by side
  public void surface_area(double side)
  {
    Console.Write("\nGiven Side : " + side);
    //Calculate surface of dodecahedron
    double area = ((3 * Math.Sqrt(25 + 10 * (Math.Sqrt(5)))) * (side * side));
    Console.Write("\nSurface area of dodecahedron : " + area + "\n");
  }
  public static void Main(String[] args)
  {
    Dodecahedron obj = new Dodecahedron();
    //Simple Case
    obj.surface_area(7);
    obj.surface_area(4);
    obj.surface_area(6.2);
  }
}

Output

Given Side : 7
Surface area of dodecahedron : 1011.64071154631

Given Side : 4
Surface area of dodecahedron : 330.331660913082

Given Side : 6.2
Surface area of dodecahedron : 793.621815343679
<?php
// Php Program
// Find surface area of dodecahedron
class Dodecahedron
{
  //Calculate surface area of dodecahedron by side
  public  function surface_area($side)
  {
    echo "\nGiven Side : ". $side;
    //Calculate surface of dodecahedron
    $area = ((3 * sqrt(25 + 10 * (sqrt(5)))) * ($side * $side));
    echo "\nSurface area of dodecahedron : ". $area ."\n";
  }
}

function main()
{
  $obj = new Dodecahedron();
  //Simple Case
  $obj->surface_area(7);
  $obj->surface_area(4);
  $obj->surface_area(6.2);
}
main();

Output

Given Side : 7
Surface area of dodecahedron : 1011.6407115463

Given Side : 4
Surface area of dodecahedron : 330.33166091308

Given Side : 6.2
Surface area of dodecahedron : 793.62181534368
// Node Js Program
// Find surface area of dodecahedron
class Dodecahedron
{
  //Calculate surface area of dodecahedron by side
  surface_area(side)
  {
    process.stdout.write("\nGiven Side : " + side);
    //Calculate surface of dodecahedron
    var area = ((3 * Math.sqrt(25 + 10 * (Math.sqrt(5)))) * (side * side));
    process.stdout.write("\nSurface area of dodecahedron : " + area + "\n");
  }
}

function main()
{
  var obj = new Dodecahedron();
  //Simple Case
  obj.surface_area(7);
  obj.surface_area(4);
  obj.surface_area(6.2);
}
main();

Output

Given Side : 7
Surface area of dodecahedron : 1011.6407115463126

Given Side : 4
Surface area of dodecahedron : 330.33166091308163

Given Side : 6.2
Surface area of dodecahedron : 793.6218153436787
#  Python 3 Program
#  Find surface area of dodecahedron

import math

class Dodecahedron :
  # Calculate surface area of dodecahedron by side
  def surface_area(self, side) :
    print("\nGiven Side : ", side, end = "")
    # Calculate surface of dodecahedron
    area = ((3 * math.sqrt(25 + 10 * (math.sqrt(5)))) * (side * side))
    print("\nSurface area of dodecahedron : ", area ,"\n", end = "")
  

def main() :
  obj = Dodecahedron()
  # Simple Case
  obj.surface_area(7)
  obj.surface_area(4)
  obj.surface_area(6.2)

if __name__ == "__main__": main()

Output

Given Side :  7
Surface area of dodecahedron :  1011.6407115463126

Given Side :  4
Surface area of dodecahedron :  330.33166091308163

Given Side :  6.2
Surface area of dodecahedron :  793.6218153436787
#  Ruby Program
#  Find surface area of dodecahedron
class Dodecahedron

  # Calculate surface area of dodecahedron by side
  def surface_area(side)
  
    #  Formula of dodecahedron surface area 
    #  3 √(25 + 10 √(5)) a²
    #  here a is side
    print("\nGiven Side : ", side)
    # Calculate surface of dodecahedron
    area = ((3 * Math.sqrt(25 + 10 * (Math.sqrt(5)))) * (side * side))
    print("\nSurface area of dodecahedron : ", area ,"\n")
  end
end
def main()

  obj = Dodecahedron.new()
  # Simple Case
  obj.surface_area(7)
  obj.surface_area(4)
  obj.surface_area(6.2)
end
main()

Output

Given Side : 7
Surface area of dodecahedron : 1011.6407115463126

Given Side : 4
Surface area of dodecahedron : 330.33166091308163

Given Side : 6.2
Surface area of dodecahedron : 793.6218153436787
// Scala Program
// Find surface area of dodecahedron
class Dodecahedron
{
  //Calculate surface area of dodecahedron by side
  def surface_area(side: Double): Unit = {
    // Formula of dodecahedron surface area 
    // 3 √(25 + 10 √(5)) a²
    // here a is side
    print("\nGiven Side : " + side);
    //Calculate surface of dodecahedron
    var area: Double = ((3 * Math.sqrt(25 + 10 * (Math.sqrt(5)))) * (side * side));
    print("\nSurface area of dodecahedron : " + area + "\n");
  }
}
object Main
{
  def main(args: Array[String]): Unit = {
    var obj: Dodecahedron = new Dodecahedron();
    //Simple Case
    obj.surface_area(7);
    obj.surface_area(4);
    obj.surface_area(6.2);
  }
}

Output

Given Side : 7.0
Surface area of dodecahedron : 1011.6407115463126

Given Side : 4.0
Surface area of dodecahedron : 330.33166091308163

Given Side : 6.2
Surface area of dodecahedron : 793.6218153436787
// Swift Program
// Find surface area of dodecahedron
import Foundation
class Dodecahedron
{
  //Calculate surface area of dodecahedron by side
  func surface_area(_ side: Double)
  {

    // Formula of dodecahedron surface area 
    // 3 √(25 + 10 √(5)) a²
    // here a is side
    print("\nGiven Side : ", side, terminator: "");
    //Calculate surface of dodecahedron
    let area: Double = ((3 * sqrt(25 + 10 * (sqrt(5)))) * (side * side));
    print("\nSurface area of dodecahedron : ", area ,"\n", terminator: "");
  }
}
func main()
{
  let obj: Dodecahedron = Dodecahedron();
  //Simple Case
  obj.surface_area(7);
  obj.surface_area(4);
  obj.surface_area(6.2);
}
main();

Output

Given Side :  7.0
Surface area of dodecahedron :  1011.64071154631

Given Side :  4.0
Surface area of dodecahedron :  330.331660913082

Given Side :  6.2
Surface area of dodecahedron :  793.621815343679


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







© 2021, kalkicode.com, All rights reserved