Program to calculate GST from original and net prices

23 Jun, 2022
Given Original cost and Net price then calculate the percentage of GSTExamples:  
Input : Netprice = 120, original_cost = 100
Output : GST = 20%

Input : Netprice = 105, original_cost = 100
Output : GST = 5%
 
How to calculate GST GST ( Goods and Services Tax ) which is included in netprice of product for get GST % first need to calculate GST Amount by subtract original cost from Netprice and then apply GST % formula = (GST_Amount*100) / original_costNetprice = original_cost + GST_Amount GST_Amount = Netprice – original_cost GST_Percentage = (GST_Amount * 100)/ original_cost  
C++
Java
Python3
C#
PHP
Javascript
// CPP Program to compute GST from original// and net prices.#include <iostream>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 functionsint main(){    float org_cost = 100;    float N_price = 120;    cout << "GST = "         << Calculate_GST(org_cost, N_price)         << " % ";    return 0;}
// 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 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 functionsorg_cost = 100N_price = 120print("GST = ",end='') print(round(Calculate_GST(org_cost, N_price)),end='') print("%") # This code is contributed# by Smitha Dinesh Semwal
// 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// PHP Program to compute GST from// original and net prices. function Calculate_GST($org_cost, $N_price){    // return value after calculate GST%    return ((($N_price - $org_cost) *                    100) / $org_cost);}     // Driver Code    $org_cost = 100;    $N_price = 120;    echo("GST = ");    echo(Calculate_GST($org_cost, $N_price));    echo(" % "); // This code is contributed// by vt_m.?>
<script>// javascript Program to compute GST// from original and net prices.     function Calculate_GST(org_cost , N_price) {        // return value after calculate GST%        return (((N_price - org_cost) * 100) / org_cost);    }     // Driver code             var org_cost = 100;        var N_price = 120;        document.write(" GST = " + Calculate_GST(org_cost, N_price) + "%"); // This code contributed by aashish1995 </script>
Output:  
GST = 20%
Time Complexity: O(1)
Auxiliary Space: O(1)
vt_m
aashish1995
shivamanandrj9
Mathematical
School Programming
Mathematical
Writing code in comment?
Please use ide.geeksforgeeks.org,
generate link and share the link here.
Merge two sorted arrays
Operators in C / C++
Prime Numbers
Minimum number of jumps to reach end
Find minimum number of coins that make a given value
Python Dictionary
Reverse a string in Java
Arrays in C/C++
Introduction To PYTHON
Interfaces in Java