Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I am wrtiting a C program to print out a bill from a carpet installation company. I have the code written and it does evrything

I am wrtiting a C program to print out a bill from a carpet installation company. I have the code written and it does evrything it is supposed to but there are some things to be fixed:

1. the calculations need to be fixed so they are not repetitive in printAmounts

2. the percent sign for the discount needs to be printed

3. get rid of the extra unneeded zeroes in the output (subtotal and total), installed price does not need the cost in the middle and same for tax

4. fix alignment of output

5. varaible names need to be length, width, laborCost, and discount

6. function names need to be: getData, calculate, and printResults

here is my program:

#include #define LABOR_COST .35 #define TAX_RATE .085 float installCost; float subtotal; float Total; void get_measurements( int *length, int *width, float *Cust_discount, float *installCost) { //begin get_measurements printf("\tEnter length of room to be carpeted (feet) and hit ENTER: "); scanf("%d", length); printf("\tEnter width of room to be carpeted (feet) and hit ENTER: "); scanf("%d", width); printf("\tEnter customer Discount (percent) and hit ENTER: "); scanf("%f", Cust_discount); printf("\tEnter cost per Square Foot of carpet (xxx.xx) and hit ENTER: "); scanf("%f", installCost); } //end get_measurements void print_measurements (int length, int width) { //begin print_measurements printf(" \t\t\t\tMeasurement "); printf(" \t\t\tLength%10.2d feet", length); printf(" \t\t\tWidth %10.2d feet", width); printf(" \t\t\tArea %10.2d sq.feet", length * width); } //end print_measurements void print_amounts (int area, float Cust_discount, float installCost) { //begin print_amounts printf(" \t\t\t\tCharges "); printf(" \tDescription\tCost/Sq.Ft.\tCharge/Room"); printf(" \t----------------------------------------------"); printf(" \tCarpet %10.2f %15.2f ", installCost, installCost * area); printf(" \tLabor %10.2f %15.2f ", LABOR_COST, LABOR_COST * area); printf(" \t\t\t\t\t----------"); printf(" \tInstalled Price %6.2f %15.2f ", installCost, ((installCost * area) + (area * LABOR_COST))); printf(" \tDiscount %6.2f %15.2f ", Cust_discount, ((.01 * Cust_discount) * ((installCost * area) + (area * LABOR_COST)))); printf(" \t\t\t\t\t----------"); printf(" \tSubTotal %0.2f %13.2f ", subtotal, (((installCost * area) + (area * LABOR_COST)) - ((.01 * Cust_discount) * ((installCost * area) + (area * LABOR_COST))))); printf(" \tTax %10.3f %15.2f ", TAX_RATE, TAX_RATE * (((installCost * area) + (area * LABOR_COST)) - ((.01 * Cust_discount) * ((installCost * area) + (area * LABOR_COST))))); printf(" \t\t\t\t\t----------"); printf(" \tTotal %10.2f %15.2f \t ", Total, ((((installCost * area) + (area * LABOR_COST)) + (TAX_RATE * (((installCost * area) + (area * LABOR_COST)) - ((.01 * Cust_discount) * ((installCost * area) + (area * LABOR_COST)))) - ((.01 * Cust_discount) * ((installCost * area) + (area * LABOR_COST))))))); } //end print_amounts void print_outcomes (int l, int w, float d, float c) { //begin print_outcomes int area = l * w; print_measurements (l, w); print_amounts (area, d, c); } //end print_outcomes int main (void) { //begin main int length, width; float installCost, Cust_discount; get_measurements ( &length, &width, &Cust_discount, &installCost); print_outcomes ( length, width, Cust_discount, installCost); return 0; } //end main

here is the output:

image text in transcribed

Here is what my output needs to be:

image text in transcribed

I can fix the function and variable names but I need help fixing the other issues. Thanks!!!

length of room Enter length of room to hit (feet) and hit ENTER: carpeted 10 Enter width of room to be carpeted (feet) and hit ENTER: 12 Enter customer Discount (percent) and hit ENTER: 12 Enter cost per Square Foot of carpet (xxx.xx) and hit ENTER: Measurement Length 10 feet 12 feet Width 120 sq. feet Area Charges Description Cost/Sq. Ft. charge/Room 15.00 1800.00 Carpet 0.35 Labor 42.00 Installed Price 15.00 1842.00 Discount 12.00 221.0 1620.96 SubTotal 0.00 0.085 137.78 Tax 0.00 1758.74 Total

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Management Databases And Organizations

Authors: Richard T. Watson

2nd Edition

0471180742, 978-0471180746

More Books

Students also viewed these Databases questions