📜  查找五角形棱镜的体积和表面积的程序

📅  最后修改于: 2021-05-06 20:30:26             🧑  作者: Mango

具有5个矩形面和2个平行五边形底面的棱镜是五角形棱镜。因此,您将获得五角棱镜的原子序长度(a) ,基长(b)和高度(h) 。您必须找到五角棱镜的表面积和体积
例子:

Input : a=3, b=5, h=6
Output :surface area=225, volume=225

Input : a=2, b=3, h=5
Output :surface area=105, volume=75

在这个图中
a –五角棱镜的原子长度。
b –五角棱镜的基本长度。
h –五角棱镜的高度。
公式:以下是计算Pythagonal Prism的表面积和体积的公式。

    $$ surface\ Area(A)= 5\times a\times b + 5\times b\times h $$

    $$ Volume(v)= \frac{5}{2}\times b\times h $$

C++
// CPP program to find
// surface area and volume of the
// Pentagonal Prism
#include 
using namespace std;
 
// function for surface area
float surfaceArea(float a, float b, float h)
{
    return 5 * a * b + 5 * b * h;
}
 
// function for VOlume
float volume(float b, float h)
{
    return (5 * b * h) / 2;
}
 
// Driver function
int main()
{
    float a = 5;
    float b = 3;
    float h = 7;
 
    cout << "surface area= " << surfaceArea(a, b, h) << ", ";
 
    cout << "volume= " << volume(b, h);
}


Java
// Java program to find
// surface area and volume of the
// Pentagonal Prism
import java.util.*;
 
class solution
{
 
// function for surface area
static float surfaceArea(float a, float b, float h)
{
 
    return 5 * a * b + 5 * b * h;
 
}
 
// function for VOlume
static float volume(float b, float h)
{
 
    return (5 * b * h) / 2;
 
}
 
// Driver function
public static void main(String arr[])
{
    float a = 5;
    float b = 3;
    float h = 7;
 
    System.out.println( "surface area= "+surfaceArea(a, b, h)+", ");
 
    System.out.println("volume= "+volume(b, h));
}
}


Python3
# Python 3 program to find surface area
# and volume of the Pentagonal Prism
 
# function for surface area
def surfaceArea(a, b, h):
    return 5 * a * b + 5 * b * h
 
# function for VOlume
def volume(b, h):
    return (5 * b * h) / 2
 
# Driver Code
if __name__ == '__main__':
    a = 5
    b = 3
    h = 7
 
    print("surface area =", surfaceArea(a, b, h),
                   ",", "volume =", volume(b, h))
 
# This code is contributed by
# Sanjit_Prasad


C#
// C# program to find surface
// area and volume of the
// Pentagonal Prism
using System;
 
class GFG
{
 
// function for surface area
static float surfaceArea(float a,
                         float b, float h)
{
    return 5 * a * b + 5 * b * h;
}
 
// function for VOlume
static float volume(float b, float h)
{
    return (5 * b * h) / 2;
}
 
// Driver Code
public static void Main()
{
    float a = 5;
    float b = 3;
    float h = 7;
 
    Console.WriteLine("surface area = " +
            surfaceArea(a, b, h) + ", ");
 
    Console.WriteLine("volume = " +
                     volume(b, h));
}
}
 
// This code is contributed by vt_m


PHP


Javascript


输出:
surface area= 180, volume= 52.5