求大神用C语言帮我编程一道题

WriteaCprigramthatpromptstheuserforacostperitem,numberofitemspurchased,andadiscountra... Write a C prigram that prompts the user for a cost per item,number of items purchased,and a discount rate.The progran should then calculate and print the total cost,discounted total cost,tax due,and amount due.Use the formulas.
total cost = number of items * cost-per-item
total cost (discounted) = total cost - (discount rate * total cost)
tax due = total cost * TAXRATE
amount due = total cost + tax due
For this problem assume that the TAXRATE is 6%
展开
 我来答
xuwang092
推荐于2016-01-23 · TA获得超过174个赞
知道小有建树答主
回答量:119
采纳率:0%
帮助的人:115万
展开全部
#include <stdio.h>
#include <math.h>
int main()
{
    double pCost,rate,totalCost,taxDue;
    int count;
    double taxRate = 0.06;
    printf("Please input the cost per item: ");
    scanf("%lf",&pCost);
    printf("Please input the number of items ");
    scanf("%d",&count);
    printf("Please input the discount rate: ");
    scanf("%lf",&rate);
    totalCost = count * pCost;
    taxDue = totalCost * taxRate;
    printf("The total cost is %lf\n",totalCost);
    printf("The discounted total cost is %lf\n",totalCost-rate*totalCost);
    printf("The tax due is %lf\n",taxDue);
    printf("Ths amount due is %lf\n",totalCost + taxDue);
    return 0;
}
推荐律师服务: 若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询

为你推荐:

下载百度知道APP,抢鲜体验
使用百度知道APP,立即抢鲜体验。你的手机镜头里或许有别人想知道的答案。
扫描二维码下载
×

类别

我们会通过消息、邮箱等方式尽快将举报结果通知您。

说明

0/200

提交
取消

辅 助

模 式