L03 - Coupons
A supermarket awards coupons depending on how much a customer spends on groceries. For example, if you spend $50, you will get a coupon worth eight percent of that amount. The following table shows the percent used to calculate the coupon awarded for different amounts spent. Write a program that calculates and prints the value of the coupon a person can receive based on groceries purchased. Use printf
to print formatted output.
Hint: Because the % symbol flags the beginning of a format specifier, if you want to actually print a % you'll need to enter it twice: %%
Here is a sample run:
Money spent | Coupon Percentage |
---|---|
Less than $10 | No coupon |
From $10 to $60 | 8% |
More than $60 to $150 | 10% |
More than $150 | 14% |
Sample Dialog
Please enter the cost of your groceries: 14
You win a discount coupon of $ 1.12. (8% of your purchase)
No Comments