Write a complete Python program that prompts a buyer to input a value for N dollars and displays/outputs how many chocolate bars a person can get and how many coupons would have leftover.
Suppose a person can buy a chocolate bar from the vending machine for $1 each. Inside every chocolate bar is a coupon. A person can redeem 3 coupons for one chocolate bar from the machine. This means that once a person has started buying chocolate bars from the machine, he/she always has some coupons. A person would like to know how many chocolate bars can be bought, if a person starts with N dollars and always redeem coupons, if he/she has enough for an additional chocolate bar.
For example:
- With 3 dollars a person could buy 4 chocolate bars after purchasing 3 bars giving him/her 3 coupons and then redeeming the 3 coupons for one bar. This would leave him/her with one extra coupon. Thus, will have 4 chocolate bars and still have one coupon leftover.
- For 11 dollars, a person can have 16 chocolate bars and still have one coupon leftover.
- For 12 dollars, a person can have 17 chocolate bars and have two coupons leftover.
Write a complete Python program that prompts a buyer to input a value for N dollars and displays/outputs how many chocolate bars a person can get and how many coupons would have leftover.
Implementation Note:
Use a loop that continues to redeem coupons as long as there are enough to get at least one chocolate bar.
can you use spyder or idle as a software. (python NOT java)
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 4 images