作业帮 > 综合 > 作业

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

来源:学生作业帮 编辑:拍题作业网作业帮 分类:综合作业 时间:2024/04/23 17:53:38
求大神用C语言帮我编程一道题
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%
#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;
}