C ++程序根据原始价格和净价格计算GST

给定原始成本和净价作为输入,任务是计算商品及服务税的百分比并显示结果

GST代表商品和服务任务。它总是包含在产品的净价中,在计算商品及服务税(GST)百分比之前,我们需要计算商品及服务税(GST)数量,为此,有可用的公式

净价=原始费用+ GSTAmount

GSTAmount =净价–原成本

GST_Percentage =(GSTAmount * 100)/原始费用

GST%公式=(GSTAmount * 100)/原价

示例

Input-: cost = 120.00
   price = 150.00
Output-: GST amount is = 25.00 %
Input-: price = 120.00
   cost = 100.00
Output-: GST amount is = 20.00 %

给定程序中使用的方法如下-

  • 将输入作为净价和原始成本

  • 应用给出的公式计算消费税百分比

  • 显示结果

算法

Start
Step 1-> declare 计算GST的功能
   float GST(float cost, float price)
   return (((price - cost) * 100) / cost)
step 2-> In main()   set float cost = 120
   set float price = 150
   call GST(cost, price)
Stop

示例

Using c++
#include <iostream>
using namespace std;
//计算GST的功能
float GST(float cost, float price) {
   return (((price - cost) * 100) / cost);
}
int main() {
   float cost = 120.00;
   float price = 150.00;
   cout << "GST amount is = "<<GST(cost, price)<<" % ";
   return 0;
}

输出结果

如果我们运行以上代码,它将在输出后产生

GST amount is = 25.00 %

使用C

示例

#include <stdio.h>
//计算GST的功能
float GST(float cost, float price) {
   return (((price - cost) * 100) / cost);
}
int main() {
   float cost = 120;
   float price = 150;
   float gst = GST(cost, price);
   printf("GST amount is : %.2f ",gst);
   return 0;
}

输出结果

如果我们运行以上代码,它将在输出后产生

GST amount is : 25.00