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

Write a C program that creates customers’ bills for a carpet company when the following information 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

The Labor cost is fixed at $0.35 per square foot. It is to be defined as constant. The tax rate is 8.5% applied after the discount. It is also to be defined as a constant. The input data consist of a set of three integers representing the length and width of the room to be carpeted, the percentage of the discount the owner gives to a customer, and a real number representing the unit price of the carpet. The program is to prompt the user for this input as shown below. (Colored numbers are typical responses.)

Length of room (feet)? 30

Width of room (feet)? 18

Customer discount (percentage)? 9

Cost per square foot (xxx.xx)? 8.32

The Output is shown below. Be careful to align the decimal points.

Measurements

Length XXX ft

Width XXX ft

Area XXX square ft

Charges

DESCRIPTION COST/SQ.FT. CHARGE

------------------- ------------------ -------------

Carpet XXX.XX $XXXX.XX

Labor 0.35 XXXX.XX

------------------------

INSTALLED PRICE $XXXX.XX

Discount XX% XXXX.XX

----------------

SUBTOTAL $XXXX.XX

Tax XXXX.XX

TOTAL $XXXX.XX

The program’s design should use main and at least the six functions described below:

a. Read data from the keyboard. This function is to use addresses to read all data and place them in the calling function’s variables.

b. Calculate values. This function calls three subfunctions. Each function is to use addresses to store their results.

• Calculate the installed price. This function calculates area, carpet cost, labor cost, and installed price. The installed price is the cost of the carpet and the cost of the labor.

• Calculate the subtotal. This function calculates the discount and subtotal.

• Calculate the total price with the discount and tax. This function calculates the tax and the total price.

c. Print the result. Use two subfunctions to print the results: one to print the results: one to print the measurements, and one to print the charges.

Test your program with the test data shown in table 4-3.

Test Length Width Discount Cost

1 23 13 12 $14.20

2 35 8 0 $8.00

3 14 11 10 $22.35

I am new to programming and I have been given this assignment but I am confused. We are using C not C++ Below is what I have so far:

float inputL();

float inputW();

float carpetP();

float carpetD();

float computeA(float l, float w);

float computeCost(float area, float price);

void display(float l, float w, float area, float cprice, float labor);

#include <stdio.h>

int main()

{

float l, w, area, price, discount, cprice;

float labor=0.35;

l=inputL();

w=inputW();

price=carpetP();

discount=carpetD();

area=computeA(l,w);

cprice=computeCost(area, price);

display(l,w,area,cprice,labor);

return 0;

}

float inputL()

{

float a;

printf("Enter Length >");

scanf("%f", &a);

return a;

}

float inputW()

{

float b;

printf("Enter Width >");

scanf("%f", &b);

return b;

}

float carpetP()

{

float c;

printf("Enter price per square foot >");

scanf("%f", &c);

return c;

}

float carpetD()

{

float d;

printf("Enter Discount per Customer >");

scanf("%f", &d);

return d;

}

float computeA(float l, float w)

{

return l*w;

}

float computeCost(float area, float price)

{

return area*price;

}

void display(float l, float w, float area, float cprice, float labor)

{

printf("\n\nMEASUREMENT\n");

printf("\nLength %.2f ft\n", l);

printf("Width %.2f ft\n", w);

printf("Area %.2f square ft\n", area);

printf("\n\nCHARGES\n\nDESCRIPTION COST/SQ.FT. CHARGE\n");

printf("Carpet %.2f %.2f\n", area, cprice);

printf("Labor %.2f %.2f\n", labor, labor);

}

Please enter comments
Please enter your name.
Please enter the correct email address.
You must agree before submitting.

Answers & Comments


Helpful Social

Copyright © 2024 1QUIZZ.COM - All rights reserved.