Programa para hallar el Area y Volumen de Icosaedro

Dado el lado de un icosaedro. La tarea es encontrar el área y el volumen del Icosaedro dado.
Ejemplos
 

Input : a = 5
Output : Area: 216.506
         Volume: 272.712

Input : a = 10
Output : Area: 866.0254
         Volume: 2181.695

En geometría, un icosaedro es un poliedro regular que contiene 20 caras triangulares equiláteras idénticas, 30 lados y 12 vértices. 
 

Area of Icosahedron

Fórmula para hallar el Área y el Volumen del Icosaedro: Sea a el lado del Icosaedro, luego 
 

Área de superficie de Icosaedro5\sqrt{3} a^{2}
y, Volumen de Icosaedro\frac{5}{12}\left ( 3 + \sqrt{5} \right )a^{3}
 

C++

// C++ program to find the Area and
// volume of Icosahedron
#include <bits/stdc++.h>
using namespace std;
 
// Function to find area of Icosahedron
float findArea(float a)
{
    float area;
 
    // Formula to calculating area
    area = 5 * sqrt(3) * a * a;
     
    return area;
}
 
// Function to find volume of Icosahedron
float findVolume(float a)
{
    float volume;
 
    // Formula to calculating volume
    volume = ((float)5 / 12) * (3 + sqrt(5)) * a * a * a;
     
    return volume;
}
 
// Driver Code
int main()
{
    float a = 5;
 
    // Function call to find area of Icosahedron.
    cout << "Area: " << findArea(a) << endl;
     
    // Function call to find volume of Icosahedron.
    cout << "Volume: " << findVolume(a);
 
    return 0;
}

Java

// Java program to find the Area and
// volume of Icosahedron
import java.io.*;
 
class GFG {
     
    // Function to find area of Icosahedron
    static float findArea(float a)
    {
        float area;
     
        // Formula to calculating area
        area = (float)(5 * Math.sqrt(3) * a * a);
         
        return area;
    }
     
    // Function to find volume of Icosahedron
    static float findVolume(float a)
    {
        float volume;
     
        // Formula to calculating volume
        volume = (float)(((float)5 / 12) * (3 + Math.sqrt(5)) * a * a * a);
         
        return volume;
    }
     
    // Driver code
    public static void main (String[] args)
    {
        float a = 5;
 
        // Function call to find area of Icosahedron.
        System.out.println("Area: " + findArea(a));
         
        // Function call to find volume of Icosahedron.
        System.out.println("Volume: " + findVolume(a));
    }
}

Python3

# Python3 program to
# find the Area and
# volume of Icosahedron
 
# import math module
# to use sqrt function
from math import sqrt
 
# Function to find
# area of Icosahedron
def findArea(a):
 
    # Formula to calculate area
    area = 5 * sqrt(3) * a * a
    return area
 
# Function to find
# volume of Icosahedron
def findVolume(a):
     
    # Formula to calculate volume
    volume = ((5 / 12) *
              (3 + sqrt(5)) *
               a * a * a)
    return volume
 
# Driver Code
a = 5
 
# Function call to
# find area of Icosahedron.
print("Area: " , findArea(a))
     
# Function call to find
# volume of Icosahedron.
print("Volume: " , findVolume(a))
 
# This code is contributed
# by ihritik

C#

// C# program to find the Area and
// volume of Icosahedron
using System;
 
public class GFG {
     
    // Function to find area of Icosahedron
    static float findArea(float a)
    {
        float area;
     
        // Formula to calculating area
        area = (float)(5 * Math.Sqrt(3) * a * a);
         
        return area;
    }
     
    // Function to find volume of Icosahedron
    static float findVolume(float a)
    {
        float volume;
     
        // Formula to calculating volume
        volume = (float)(((float)5 / 12) * (3 + Math.Sqrt(5)) * a * a * a);
         
        return volume;
    }
     
    // Driver code
    static public void Main ()
    {
        float a = 5;
 
        // Function call to find area of Icosahedron.
        Console.WriteLine("Area: " + findArea(a));
         
        // Function call to find volume of Icosahedron.
        Console.WriteLine("Volume: " + findVolume(a));
        //Code
    }
}

PHP

<?php
// PHP program to find
// the Area and volume
// of Icosahedron
 
// Function to find area
// of Icosahedron
function findArea($a)
{
    $area;
 
    // Formula to
    // calculating area
    $area = 5 * sqrt(3) *
                $a * $a;
     
    return $area;
}
 
// Function to find
// volume of Icosahedron
function findVolume($a)
{
    $volume;
 
    // Formula to
    // calculating volume
    $volume = ((float)5 / 12) *
                (3 + sqrt(5)) *
                  $a * $a * $a;
     
    return $volume;
}
 
// Driver Code
$a = 5;
 
// Function call to find
// area of Icosahedron.
echo "Area: " , findArea($a), "\n";
 
// Function call to find
// volume of Icosahedron.
echo "Volume: " , findVolume($a);
 
// This code is contributed
// by jit_t
?>

Javascript

<script>
// javascript program to find the Area and
// volume of Icosahedron
 
// Function to find area of Icosahedron
function findArea( a)
{
    let area;
 
    // Formula to calculating area
    area = 5 * Math.sqrt(3) * a * a;
     
    return area;
}
 
// Function to find volume of Icosahedron
function findVolume( a)
{
    let volume;
 
    // Formula to calculating volume
    volume = (5 / 12) * (3 + Math.sqrt(5)) * a * a * a;
     
    return volume;
}
 
// Driver Code
    let a = 5;
 
    // Function call to find area of Icosahedron.
    document.write( "Area: " + findArea(a).toFixed(3) +"<br/>");
     
    // Function call to find volume of Icosahedron.
    document.write("Volume: " + findVolume(a).toFixed(3));
     
// This code is contributed by todaysgaurav
 
</script>
Producción: 

Area: 216.506
Volume: 272.712

 

Complejidad de Tiempo : O(1)
Espacio Auxiliar : O(1)

Publicación traducida automáticamente

Artículo escrito por Kanishk_Verma y traducido por Barcelona Geeks. The original can be accessed here. Licence: CCBY-SA

Deja una respuesta

Tu dirección de correo electrónico no será publicada. Los campos obligatorios están marcados con *