Gas Loyalty
Several grocery stores have programs that encourage customer loyalty. In one common approach, a customer has a card from the grocery store that keeps track of the amount the customer has spent at the store in the last two weeks. Based upon the total expenditure, the customer is entitled to a discount at a cooperating gas station. The following table shows a hypothetical type of discount policy that represents a composite of several store programs:
| Amount Spent at Grocery Store | Discount per Gallon on Gas | Maximum Number of Gallons at Discounted Price |
|---|---|---|
| $0.00–$39.99 | no discount | no discount |
| $40.00–$79.99 | 2 cents per gallon | up to 15 gallons |
| $80.00–$99.99 | 2 cents per gallon | no limit on gallons |
| $100.00–$129.99 | 5 cents per gallon | up to $1.50 discount |
| $130.00–$149.99 | 5 cents per gallon | no limit on gallons |
| $150.00–$174.99 | 9 cents per gallon | up to 17 gallons |
| $175.00 or more | 12 cents per gallon | no limit on gallons |
Write a program that begins with initialized variables for the two-week total for grocery purchases, a price per gallon for gas (before any discount), and the number of gallons purchased. The program should print:
- the initial data (grocery purchases, gasoline price per gallon, and number of gallons purchases)
- the total cost for the gasoline, before discount,
- the actual discount received (covering all gallons, not the actual price per gallon), and
- the total price paid actually paid for the gas.
The program gas-loyalty.c
is a sample start for this C program. Remember to include the
necessary additional headers in your final submission.
Grading
In addition to the general grading guidelines for evaluation, the assignment is worth 25 points.
- [14 points] Computation of the discount
- [2 points] Correct computation if customer spends $39.99 or less
- [2 points] Correct computation if customer spends $40.00–$79.99
- [2 points] Correct computation if customer spends $80.00–$99.99
- [2 points] Correct computation if customer spends $100.00–$129.99
- [2 points] Correct computation if customer spends $130.00–$149.99
- [2 points] Correct computation if customer spends $150.00–$174.99
- [2 points] Correct computation if customer spends $175.00 or more
- [3 points] Computation of the total price paid before the discount is applied
- [3 points] Computation of the actual price paid by the customer
-
Comments on Program Format, Comments, Readability, etc.
(Points not given, but points can be deducted.) -
[5 points] Testing
- Test Plan with a numbered listing of the circumstances that can reasonably arise in this problem
- Listing of test cases to be considered, with the expected outcome
- Listing of actual test runs
- Statement of why the program is correct
