📌  相关文章
📜  如果将长度,宽度和高度增加固定百分比,则长方体体积的百分比增加

📅  最后修改于: 2021-05-05 01:48:52             🧑  作者: Mango

给定一个长方体和三个整数LBH。如果长方体的长度增加L% ,则宽度增加B%,而高度增加H% 。任务是找到长方体体积的百分比增加。

例子:

方法:假设长方体的原始长度,宽度和高度分别为lbh 。现在,增加的长度将是(l +((L * l)/ 100)),即,增加的长度= l *(1 +(L / 100)) 。类似地,增加的宽度和高度将增加Beadth = b *(1 +(B / 100)),增加的Height = h *(1 +(H / 100))
现在,计算originalVol = l * b * h,增加volumeVolume =增加长度*增加宽度*增加高度
并且,增加的百分比可以找到为((increasedVol – originalVol)/ originalVol)* 100

下面是上述方法的实现:

C++
// C++ implementation of the approach
#include 
using namespace std;
  
// Function to return the percentage increase
// in the volume of the cuboid
double increaseInVol(double l, double b, double h)
{
    double percentInc = (1 + (l / 100))
                        * (1 + (b / 100))
                        * (1 + (h / 100));
    percentInc -= 1;
    percentInc *= 100;
  
    return percentInc;
}
  
// Driver code
int main()
{
    double l = 50, b = 20, h = 10;
    cout << increaseInVol(l, b, h) << "%";
  
    return 0;
}


Java
// Java implementation of the approach
class GFG
{
      
// Function to return the percentage increase
// in the volume of the cuboid
static double increaseInVol(double l,   
                            double b, 
                            double h)
{
    double percentInc = (1 + (l / 100)) * 
                        (1 + (b / 100)) * 
                        (1 + (h / 100));
    percentInc -= 1;
    percentInc *= 100;
  
    return percentInc;
}
  
// Driver code
public static void main(String[] args)
{
    double l = 50, b = 20, h = 10;
    System.out.println(increaseInVol(l, b, h) + "%");
}
}
  
// This code is contributed by Code_Mech


Python3
# Python3 implementation of the approach
  
# Function to return the percentage increase
# in the volume of the cuboid
def increaseInVol(l, b, h):
    percentInc = ((1 + (l / 100)) * 
                  (1 + (b / 100)) * 
                  (1 + (h / 100)))
    percentInc -= 1
    percentInc *= 100
  
    return percentInc
  
# Driver code
l = 50
b = 20
h = 10
print(increaseInVol(l, b, h), "%")
  
# This code is contributed by Mohit Kumar


C#
// C# implementation of the approach
using System;
  
class GFG
{
      
// Function to return the percentage increase
// in the volume of the cuboid
static double increaseInVol(double l, 
                            double b, 
                            double h)
{
    double percentInc = (1 + (l / 100)) * 
                        (1 + (b / 100)) * 
                        (1 + (h / 100));
    percentInc -= 1;
    percentInc *= 100;
  
    return percentInc;
}
  
// Driver code
public static void Main()
{
    double l = 50, b = 20, h = 10;
    Console.WriteLine(increaseInVol(l, b, h) + "%");
}
}
  
// This code is contributed by Code_Mech


输出:
98%