Dado el costo original y el precio neto, calcule el porcentaje de GST
Ejemplos:
Input : Netprice = 120, original_cost = 100 Output : GST = 20% Input : Netprice = 105, original_cost = 100 Output : GST = 5%
Cómo calcular el GST
GST (impuesto sobre bienes y servicios) que se incluye en el precio neto del producto para obtener el % del GST, primero debe calcular el monto del GST restando el costo original del precio neto y luego aplicar la
fórmula del % del GST = (GST_Amount*100) / original_cost
Netprice = coste_original + Importe_GST
Importe_GST = Precio neto –
coste_original Porcentaje_GST = (Importe_GST * 100)/ coste_original
C++
// 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 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
<?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. ?>
Javascript
<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>
Producción:
GST = 20%
Complejidad de tiempo: O(1)
Espacio Auxiliar: O(1)