📌  相关文章
📜  如果更改半径,则半球体积的百分比变化

📅  最后修改于: 2021-04-22 08:12:07             🧑  作者: Mango

鉴于半球的半径以固定百分比变化,因此目标是计算半球体积变化的百分比。

方法:

  • 令,半球的半径= a
  • 给定百分比增长= x%
  • 增长前的数量= \frac{2}{3} * 3.14*a^3
  • 增加后的新半径= a + \frac{ax}{100}
  • 因此,新体积= \frac{2}{3}*3.14*(a^3 + (\frac{ax}{100})^3 + \frac{3a^3x}{100} + \frac{3a^3x^2}{10000})
  • 音量变化= \frac{2}{3}*3.14*((\frac{ax}{100})^3 + \frac{3a^3x}{100} + \frac{3a^3x^2}{10000})
  • 数量增加百分比
    = (\frac{2}{3}*3.14*((\frac{ax}{100})^3 + \frac{3a^3x}{100} + \frac{3a^3x^2}{10000})/\frac{2}{3}*3.14*a^3) * 100
    = \frac{x^3}{10000} + 3x + \frac{3x^2}{100}

下面是上述方法的实现:

CPP
// C++ program to find percentage change
// in hemisphere volume wrt change in radius
  
#include 
#include 
using namespace std;
  
// Function to find the change
// in hemispheric volume
void new_vol(double x)
{
  
    if (x > 0) {
  
        cout << "% change in the "
             << "volume of the hemisphere: "
             << pow(x, 3) / 10000 + 3 * x
                    + (3 * pow(x, 2)) / 100
             << "%"
             << " increase\n";
    }
  
    else if (x < 0) {
  
        cout << "% change in the "
             << "volume of the hemisphere: "
             << pow(x, 3) / 10000 + 3 * x
                    + (3 * pow(x, 2)) / 100
             << "% decrease\n";
    }
  
    else {
        cout << "Volume remains the same.";
    }
}
  
// Driver code
int main()
{
  
    // Get the change in radius
    double x = -10.0;
  
    // Calculate the change in hemispheric volume
    new_vol(x);
  
    return 0;
}


Java
// Java program to find percentage change
// in hemisphere volume wrt change in radius
class GFG
{
  
// Function to find the change
// in hemispheric volume
static void new_vol(double x)
{
  
    if (x > 0)
    {
  
        System.out.print("% change in the "
            + "volume of the hemisphere: "
            + (Math.pow(x, 3) / 10000 + 3 * x
                    + (3 * Math.pow(x, 2)) / 100)
            + "%"
            + " increase\n");
    }
  
    else if (x < 0) 
    {
  
        System.out.print("% change in the "
            + "volume of the hemisphere: "
            + (Math.pow(x, 3) / 10000 + 3 * x
                    + (3 * Math.pow(x, 2)) / 100)
            + "% decrease\n");
    }
  
    else 
    {
        System.out.print("Volume remains the same.");
    }
}
  
// Driver code
public static void main(String[] args)
{
  
    // Get the change in radius
    double x = -10.0;
  
    // Calculate the change in hemispheric volume
    new_vol(x);
}
}
  
// This code is contributed by Rajput-Ji


Python
# Python3 program to find percentage change
# in hemisphere volume wrt change in radius
  
  
# Function to find the change
# in hemispheric volume
def new_vol(x):
  
    if (x > 0):
  
        print("% change in the volume of the hemisphere: ", pow(x, 3) / 10000 + 3 * x + (3 * pow(x, 2)) / 100,"% increase")
  
    elif (x < 0):
  
        print("% change in the volume of the hemisphere: ", pow(x, 3) / 10000 + 3 * x + (3 * pow(x, 2)) / 100,"% decrease")
  
    else:
        print("Volume remains the same.")
# Driver code
  
# Get the change in radius
x = -10.0
  
# Calculate the change in hemispheric volume
new_vol(x)
  
# This code is contributed by mohit kumar 29


C#
// C# program to find percentage change
// in hemisphere volume wrt change in radius
using System;
  
class GFG
{
  
    // Function to find the change
    // in hemispheric volume
    static void new_vol(double x)
    {
        if (x > 0)
        {
      
            Console.Write("% change in the "
                + "volume of the hemisphere: "
                + (Math.Pow(x, 3) / 10000 + 3 * x
                        + (3 * Math.Pow(x, 2)) / 100)
                + "%"
                + " increase\n");
        }
      
        else if (x < 0) 
        {
      
            Console.Write("% change in the "
                + "volume of the hemisphere: "
                + (Math.Pow(x, 3) / 10000 + 3 * x
                        + (3 * Math.Pow(x, 2)) / 100)
                + "% decrease\n");
        }
      
        else
        {
            Console.Write("Volume remains the same.");
        }
    }
      
    // Driver code
    public static void Main()
    {
      
        // Get the change in radius
        double x = -10.0;
      
        // Calculate the change in hemispheric volume
        new_vol(x);
    }
}
  
// This code is contributed by AnkitRai01


输出:
% change in the volume of the hemisphere: -27.1% decrease