求大神用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.
来源:学生作业帮助网 编辑:六六作业网 时间:2024/12/24 11:23:25
求大神用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.
求大神用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%
求大神用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.
#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;
}