CSC 161 Schedule Readings Labs & Projects Homework Deadlines Resources

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 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.