/* * * Program prompts you for length and width of a garden plot * and reports the total amount of fencing and the cost of * the fenceing * */ #include #define FENCE_PRICE_PER_FOOT 1.13 /* function prototype */ double calculate_cost_fence ( int l, int w); int main() { int length; int width; double cost; double quarter_payment; printf("############################################################\n"); printf("############################################################"); printf("\n\nThis program will calculate the amount of fencing \n\tat the cost at $%0.2f per foot\n\tfor a rectangular garden plot.\n", FENCE_PRICE_PER_FOOT); printf("\nEnter the length of your Garden plot in whole feet => "); scanf("%d", &length); printf("\nEnter the width of your Garden plot in whole feet => "); scanf("%d", &width); printf("\n"); cost = calculate_cost_fence ( length, width ); quarter_payment = cost/4; printf("\nThis fencing can be financed for four monthly payments of $%0.2f!\n\n", quarter_payment); printf("############################################################\n"); printf("############################################################\n\n"); return 0; } double calculate_cost_fence ( int l, int w ) { int totalFencing = 2 * (l + w ); double cost = (double)totalFencing * FENCE_PRICE_PER_FOOT; printf("\nFor a plot %d in length and %d in width,\n\t You will need %d feet of fencing,\n\t Costing you $%0.2f! \n", l,w,totalFencing, cost); return cost; }