Description
The purpose of this challenge is examine the output and write the C++ source code that produces the given output and interaction.
Requirements
- You may use any combination of variable declarations, assignments, conditional statements, expressions, loops, etc. You may write as many functions as you deem necessary.
- Hint: use a file to store coupon codes. You will need to read and write to this file.
Sample Interaction / Output
$ [ run your program ] 1 - Test a coupon code 2 - Create a coupon code Command: 1 Enter an amount: 20.00 Enter a coupon code: HALLOWEEN Invalid coupon code - amount unchanged Enter a coupon code: FALLFEST Coupon applied - 10% off Total amount due: 18.00 $ [ run your program ] 1 - Test a coupon code 2 - Create a coupon code Command: 1 Enter an amount: 100.00 Enter a coupon code: FALLFEST Coupon applied - 10% off Total amount due: 90.00 $ [ run your program ] 1 - Test a coupon code 2 - Create a coupon code Command: 1 Enter an amount: 50.00 Enter a coupon code: FALLFEST FALLFEST has reached maximum redemptions - no longer valid Enter a coupon code: PUMPKIN Coupon applied - 50% off Total amount due: 25.00 $ [ run your program ] 1 - Test a coupon code 2 - Create a coupon code Command: 2 Enter a coupon code: SCARY Enter the percentage discount: 0.25 Enter the number of allowed uses: 1 $ [ run your program ] 1 - Test a coupon code 2 - Create a coupon code Command: 1 Enter an amount: 100.00 Enter a coupon code: SCARY Coupon applied - 25% off Total amount due: 75.00 $ [ run your program ] 1 - Test a coupon code 2 - Create a coupon code Command: 1 Enter an amount: 40.00 Enter a coupon code: SCARY SCARY has reached maximum redemptions - no longer valid Invalid coupon code - amount unchanged Enter a coupon code: PUMPKIN Coupon applied - 50% off Total amount due: 20.00
LEGEND
PROGRAM OUTPUT
USER INPUT
FROM INPUT
CATALOG ID: CPP-BB0003
Print Requirements