1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

GUYS!! pleeeeeassse HELP ME w/ this one

Discussion in 'C' started by PLM, Sep 29, 2011.

  1. PLM

    PLM New Member

    Joined:
    Sep 26, 2011
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    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


    thanks in advance for your help c: God bless!!
     
  2. sam

    sam New Member

    Joined:
    Jun 4, 2011
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    PLM,you have to specify what particular problem you are facing with this question-and i'll try to help you out.have you tried any code?if yes then send it to me and i'll see it.i want you to make the code yourself and i m willing to help you as well as i can.trust me thats the best way to learn c++.
    please specify your problem.
     
  3. PLM

    PLM New Member

    Joined:
    Sep 26, 2011
    Messages:
    6
    Likes Received:
    0
    Trophy Points:
    0
    Sam,this is my code :)

    Code:
    #include<stdio.h>
    #include<conio.h>
    int computation1(int l, int w, float cc, float *ccost, float 
    
    *lcost, float *ip);
    int computation2(float ip, int dc, float *discount, float *st);
    int computation3(float st, float *tax, float *total);
    void measurement(int len, int wid, int area);
    void charges(float cc, float ccost, float lcost, float ip, int 
    
    dc, float discount, float st, float tax, float total);
    int main(void)
    {int len=0,wid=0,dc=0;
    float cc=0, ccost=0, lcost=0, ip=0, discount=0, st=0, tax=0, 
    
    total=0;
    clrscr();
    printf("Length of room? : ");scanf("%d", &len);
    printf("Width of room? : ");scanf("%d", &wid);
    printf("Customer discount? : ");scanf("%d", &dc);
    printf("Cost per square foot : ");scanf("%f", &cc);
    computation1(len,wid,cc,&ccost,&lcost,&ip);
    computation2(ip,dc,&discount,&st);
    computation3(st,&tax,&total);
    charges(cc,ccost,lcost,ip,dc,discount,st,tax,total);
    return 0;
    }
    
    
    int computation1(int l, int w, float cc, float *ccost, float 
    
    *lcost, float *ip)
    {
    int area=0;
    area=l*w;
    *ccost=area*cc;
    *lcost=area*.35;
    *ip=*ccost+*lcost;
    measurement(l,w,area);
    return 0;
    }
    
    
    int computation2(float ip, int dc, float *discount, float *st)
    {
    *discount=ip*(dc*.01);
    *st=ip-*discount;
    return 0;
    }
    
    
    int computation3(float st, float *tax, float *total)
    {
    *tax=st*.085;
    *total=st+*tax;
    return 0;
    }
    
    
    void measurement(int len, int wid, int area)
    {clrscr();
    printf(" MEASUREMENT \n\n");
    printf("Length %8d ft\n", len);
    printf("Width %8d ft\n", wid);
    printf("Area %8d square ft", area);
    getch();
    }
    
    
    void charges(float cc, float ccost, float lcost, float ip, int 
    
    dc, float discount, float st, float tax, float total)
    {
    printf("\n\n\n\n CHARGES \n\n");
    printf("DESCRIPTION COST/SQ.FT. CHARGE \n");
    printf("----------- ----------- ---------------\n");
    printf("Carpet %5.2f $ %10.2f\n", cc, ccost);
    printf("Labor 0.35 %10.2f\n", lcost);
    printf(" ---------------\n");
    printf("INSTALLED PRICE $ %10.2f\n", ip);
    printf("Discount %3d %10.2f\n", dc, discount);
    printf(" ---------------\n");
    printf("SUBTOTAL $ %10.2f\n", st);
    printf("Tax %10.2f\n", tax);
    printf("TOTAL $ %10.2f\n", total);
    getch();
    }
     
  4. sam

    sam New Member

    Joined:
    Jun 4, 2011
    Messages:
    12
    Likes Received:
    0
    Trophy Points:
    0
    sorry,PLM-i thought it was c++.i dont really know C.wish i could help you.i really do.if it were c++ i would have been able to help you out.but i havn't learned C.
    sorry for wasting your time.
    sorry again bro:(
    wish you all the best!
     

Share This Page