CS361 Programming Assignment 4

CS361 Programming Assignment 4

CS361 Programming Assignment 4
Program #1

A department store would like you to write a program to compute the bills for an upcoming sale.

You will also write a test plan for this program.
The store is offering discounts to customers, based on the customer type and amount of purchase.
The following discounts will be offered:

Total amount of purchase GeneralPublic 


Store Rewards

Club Member

Under 50 3%


50 to under 100 5% 7%

100 to under 200  8% 12%

200 or over

16% 20%


Store Credit
Card Holder
additional 5%
if Gold Card

1.  All of the fixed values in the table should be stored as constants, using descriptive constant names.  This means that you will need to create constants for the purchase limit dollar amounts in each bracket, as well as for the rates in each bracket.

2.  The store should be able to modify any of the figures, simply by changing the constant values, and without having to modify any of the executable code. 

3. Do not embed any constant values in the constant names!


  const double CLUB_RATE_50_OR_OVER = 0.07;  // incorrect
The above constant is defined incorrectly, because the purchase minimum of 50 is embedded in the constant name.  Instead, a separate constant should be defined to hold the minimum:

  const int MIN_PURCH_RATE2 = 50.00;

  const double CLUB_RATE2 = 0.07;       // better!
Program Implementation 

The program should first describe its purpose to the user.  Then it should prompt for and read the customer type and purchase amount from the user.   

Note:  The program does not have to error check any of the user input -- you may assume all valid answers will be entered. But the program must accept both upper and lowercase entries of any character input.

If the customer is a credit card holder, the program should also prompt for the credit card type. 

Input Example 2 

Department Store Sale Bill Calculator 

Customer Type Choices:

    P – general public

    R – rewards club member

    C – credit card holder 

Enter customer type: R 

Enter total amount of purchase: 55.44 

Department Store Sale Bill Calculator 

Customer Type Choices:

    P – general public

    R – rewards club member

    C – credit card holder 

Enter customer type: c 

Enter total amount of purchase: 144 

Credit card type (S for standard, G for gold): g

After reading all necessary input, the program will call a user-defined function to determine which discount rate to apply.  The user-defined function will:

 Be given a descriptive name that describes what task the function performs.

 Have two input parameters: customer type and purchase total

o Possible customer types that can be passed in are:

 P = general-public

 R = rewards club

 S  = standard card holder

 G = gold card holder 

 Use BOTH nested if statement(s) AND extended multi-way selection if statement(s) to determine the correct discount rate for the customer.

 Return a discount rate to the main function.

The main function will use the returned discount rate to compute the customer’s discount.  
After applying the discount, the customer will be charged sales tax on their purchase, at the sales tax rate of 7.5%.  

Finally, the program should neatly display the customer type, discount rate, and bill details.

NOTE:  No switch statements shall be used in this program.
Output Example 1 (using Input Example 1 data) 

Notes on output:

1. The customer type should be displayed in words (not just a character) and line up on the right with the dollar figures below.

2. Rate used should be displayed as a whole number and line up on the right with the dollar figures below.

3. The sales tax should be displayed using a defined constant name (not a hardcoded value).

4. All dollars and cents amounts should be displayed to 2 decimal places and aligned on the decimal point 
Output Example 2 (using Input Example 2 data)

Department Store Bill 

  Customer Category:          Rewards Club

  Discount Rate:                        7%


  Total Purchase Amount:        $    55.44

  Less Discounted Amount:       $     3.88


  Subtotal after discount:      $    51.56

  Plus Sales Tax (7.5%)         $     3.87

  Total Bill:                   $    55.43

Department Store Bill 

  Customer Category:      Gold Card Holder

  Discount Rate:                       25%

  Total Purchase Amount:        $   144.00

  Less Discounted Amount:       $    36.00


  Subtotal after discount:      $   108.00

  Plus Sales Tax (7.5%)         $     8.10


  Total Bill:                   $   116.10

As part of your submission for this week, you must write a test plan for this program. 

Your test plan must include both rationale for testing all conditions within the program and a list of the specific test cases.  Each test case must include the exact user input used for the test and what the exact output expected. 

A test plan for one of last week’s programs is included in the online Content as a sample (see section 4.3.3). 

The test plan should be submitted in either a Word document or an Excel spreadsheet.
Powered by