1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111
|
#include <stdio.h>
float inputData(float length, float width, float discount, float price);
float calcInstall (float area, float price, float laborCost);
float calcSubTotal(float discount, float iPrice);
float caclTotal(float subTotal, float tax);
float calculate (float area, float discount, float price, float laborCost, float iPrice, float subTotal, float tax);
float printMeasurements(float length, float width);
float printtCharges (float area, float discount, float price, float subTotal, float total, float tax, float laborCost, float iPrice);
float printtResults(float length, float width, float discount, float price);
int main()
{
float length, width, area;
float price, discount, iPrice, subTotal, total;
const laborCost=0.09;
const tax=0.05;
inputData(length, width, discount, price);
iPrice=calcInstall(area, price, laborCost);
subTotal=calcSubTotal(discount, iPrice);
total=calcTotal(subTotal, tax);
calculate (area, discount, price, laborCost, iPrice, subTotal, tax);
printMeasurements(length, width);
printCharges (area, discount, price, subTotal, total, tax, laborCost, iPrice);
printResults(length, width, discount, price, area );
return 0;
}
float inputData(float length, float width, float discount, float price)
{
printf("\nLength of Room (in feet) >");
scanf("%d", &length);
printf("\nWidth of Room (in feet) >");
scanf("%d", &width);
printf("\nCustomers discount (in percent) >");
scanf("%f", &discount);
printf("\nCost per square foot (000.00) >");
scanf("%f", &price);
}
float calcInstall (float area, float price, float laborCost)
{
return (price + laborCost) * area;
}
float calcSubTotal(float discount, float iPrice)
{
return iPrice - discount * iPrice * 0.01;
}
float caclTotal(float subTotal, float tax)
{
return subTotal + ( subTotal * tax );
}
float calculate (float area, float discount, float price, float laborCost, float iPrice, float subTotal, float tax)
{
calcInstall(area, price, laborCost);
calcSubTotal(discount, iPrice);
caclTotal(subTotal, tax);
}
float printMeasurements(float length, float width)
{
printf("\n\n\t\t\t\tMeasurement\n");
printf("\n\t\t\tLength %10d feet", length);
printf("\n\t\t\tWidth %10d feet", width);
printf("\n\t\t\tArea %10d feet", length * width);
}
float printCharges (float area, float discount, float price, float subTotal, float total, float tax, float laborCost, float iPrice)
{
calculate (area, discount, price, laborCost, iPrice, subTotal, tax)
printf("\n\n\t\t\t\tCharges\n");
printf("\n\tDESCRPTION\tCOST/SQ.FT.\tCHARGE/ROOM");
printf("\n\t--------------------------------------------");
printf("\n\tCarpet %15.2f %14.2f $", price, price * area);
printf("\n\tLabor %15.2f %14.2f $", laborCost, laborCost * area);
printf("\n\t\t\t\t---------------");
printf("\n\tInstalled Price %21.2f $", iPrice);
printf("\n\tDiscount %13.2f %14.2f $", discount, discount * iPrice * 0.01);
printf("\n\t\t\t\t---------------");
printf("\n\tSub Total %27.2f $", subTotal);
printf("\n\tTax %33.2f $", subTotal * tax);
printf("\n\t\t\t\t---------------");
printf("\n\tTotal %31.2f $\n\n\t", total);
}
void printResults(float length, float width, float discount, float price)
{
float area= length * width;
printMeasurements(length, width);
printCharges(area, discount, price);
}
| |