C.I.S. 1.5

Brooklyn College

Professor Langsam

 

Program #4

 

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 a constant. The tax rate is 8.5% applied after the discount. It is also to be defined as a C++ 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 floating point number representing the unit price of the carpet. The program is to prompt the user for this input as shown below. (Bold italic numbers are typical responses.) Give the user instructions as to how to terminate the program.

 

  Length of room (feet)? 30

  Width of room (feet)? 18

  Customer discount (percent)? 9

  Cost per square foot (xxx.xx)? 8.23

 

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

 

          THE BROOKLYN COLLEGE CARPET STORE

               YourName, Owner

 

                  MEASUREMENT

 

             Length     xxx feet

             Width      xxx feet

             Area       xxx square feet

 

 

 

                    CHARGES

 

  DESCRIPTION      COST/SQ.FT.   CHARGE/ROOM

  Carpet              xxx.xx         $xxxx.xx

  Labor                 0.35         xxxx.xx

                                     --------

  INSTALLED PRICE                      $xxxx.xx

  Discount            xx.x%         xxxx.xx

                                     --------

 

  SUBTOTAL                           $xxxx.xx

  Tax                                  xxx.xx

  TOTAL                              $xxxx.xx

 

The program's design should use main and at least the seven functions described below:

 

1.     Read the data (getData) from the keyboard. This function is to use a call-by-reference technique to read all data and place it in the calling function’s variables.

 

2.     Calculate values (calculate). This function calls three subfunctions.

a.      Calculate the installed price (calcInstall). The installed price is the cost the carpet and the cost of the labor.

b.     Calculate the subtotal (calcSubTotal).

c.      Calculate the total price with discount and tax (calcTotal).

 

3.     Print the result (printResult).  Use two subfunctions to print the results, one to print the measurements and one to print the charges. Each customer’s invoice is to be printed on a separate sheet of paper, and is to have headings of your own design. All printing is to be done to a file.

 

 

Test your program with the following three sets of data:

 

               Test          Length        Width       Discount      Price

                 1                  23               13                12               14.20

                 2                  35                 8                  0                 8.00

                 3                  14               11                10               22.25

 

Create an additional two set of data.

 

 

 

 

 

 

 

 

 

 

 

 

(HW4c_c.doc – 03/15/07)