📜  从原始价格和净价格计算商品及服务税的程序

📅  最后修改于: 2021-04-29 18:00:51             🧑  作者: Mango

给定原始成本和净价,然后计算商品及服务税的百分比
例子:

Input : Netprice = 120, original_cost = 100
Output : GST = 20%

Input : Netprice = 105, original_cost = 100
Output : GST = 5%

如何计算消费税
产品净价中包含的商品及服务税(GST),是要获取商品及服务税(GST)%,首先需要通过从商品净价中减去原始成本来计算商品及服务税(GST)金额,然后应用
GST%公式= (GST_Amount * 100)/原始成本
净价=原始成本+ GST_Amount
GST_Amount =净价–原成本
GST_Percentage =(GST_Amount * 100)/ original_cost

C++
// CPP Program to compute GST from original
// and net prices.
#include 
using namespace std;
 
float Calculate_GST(float org_cost, float N_price)
{
    // return value after calculate GST%
    return (((N_price - org_cost) * 100) / org_cost);
}
// Driver program to test above functions
int main()
{
    float org_cost = 100;
    float N_price = 120;
    cout << "GST = "
         << Calculate_GST(org_cost, N_price)
         << " % ";
    return 0;
}


Java
// Java Program to compute GST
// from original and net prices.
import java.io.*;
 
class GFG
{
    static float Calculate_GST(float org_cost,
                                  float N_price)
    {
        // return value after calculate GST%
        return (((N_price - org_cost) * 100)
                 / org_cost);
    }
     
    // Driver code
    public static void main (String[] args)
    {
         float org_cost = 100;
        float N_price = 120;
        System.out.print(" GST = "  + Calculate_GST
                         (org_cost, N_price) + "%");
    }
}
 
// This code is contributed
// by vt_m.


Python3
# Python3 Program to
# compute GST from original
# and net prices.
 
def Calculate_GST(org_cost, N_price):
 
    # return value after calculate GST%
    return (((N_price - org_cost) * 100) / org_cost);
 
# Driver program to test above functions
org_cost = 100
N_price = 120
print("GST = ",end='')
 
print(round(Calculate_GST(org_cost, N_price)),end='')
 
print("%")
 
# This code is contributed
# by Smitha Dinesh Semwal


C#
// C# Program to compute GST
// from original and net prices.
using System;
 
class GFG
{
    static float Calculate_GST(float org_cost,
                                float N_price)
    {
        // return value after calculate GST%
        return (((N_price - org_cost) * 100)
                / org_cost);
    }
     
    // Driver code
    public static void Main ()
    {
        float org_cost = 100;
        float N_price = 120;
        Console.Write(" GST = " + Calculate_GST
                        (org_cost, N_price) + "%");
    }
}
 
// This code is contributed
// by vt_m.


PHP


Javascript


输出:

GST = 20%