How To Write a C program that creates customers' bills for a carpet company when the following is given ?

Write a C program that creates customers' bills for a carpet company when the following is given:


a. the length and the width of the carpet in feet.
b. the carpet price per square foot.
c. the percent of discount for each customer.


  1. float inputL();
  2. float inputW();
  3. float carpetP();
  4. float carpetD();
  5. float computeA(float l, float w);
  6. float computeCost(float area, float price);
  7. void display(float l, float w, float area, float cprice, float labor);
  8.  
  9. #include <stdio.h>
  10.  
  11. int main()
  12. {
  13.         float l, w, area, price, discount, cprice;
  14.         float labor=0.35;
  15.        
  16.         l=inputL();
  17.         w=inputW();
  18.         price=carpetP();
  19.         discount=carpetD();
  20.         area=computeA(l,w);
  21.         cprice=computeCost(area, price);
  22.         display(l,w,area,cprice,labor);
  23.         return 0;
  24.        
  25. }
  26.  
  27. float inputL()
  28. {
  29.         float a;
  30.         printf("Enter Length >");
  31.         scanf("%f", &a);
  32.         return a;
  33. }
  34.  
  35. float inputW()
  36. {
  37.         float b;
  38.         printf("Enter Width >");
  39.         scanf("%f", &b);
  40.         return b;
  41. }
  42.  
  43. float carpetP()
  44. {
  45.         float c;
  46.         printf("Enter price per square foot >");
  47.         scanf("%f", &c);
  48.         return c;
  49. }
  50.  
  51. float carpetD()
  52. {
  53.         float d;
  54.         printf("Enter Discount per Customer >");
  55.         scanf("%f", &d);
  56.         return d;
  57. }
  58.  
  59. float computeA(float l, float w)
  60. {
  61.         return l*w;
  62. }
  63.  
  64. float computeCost(float area, float price)
  65. {
  66.         return area*price;
  67. }
  68.  
  69. void display(float l, float w, float area, float cprice, float labor)
  70. {
  71.         printf("\n\nMEASUREMENT\n");
  72.         printf("\nLength       %.2f ft\n", l);
  73.         printf("Width        %.2f ft\n", w);
  74.         printf("Area        %.2f square ft\n", area);
  75.        
  76.         printf("\n\nCHARGES\n\nDESCRIPTION     COST/SQ.FT.      CHARGE\n");
  77.         printf("Carpet           %.2f             %.2f\n", area, cprice);
  78.         printf("Labor            %.2f             %.2f\n", labor, labor);
  79. }


Learn More :