Absolute C++
Absolute C++
6th Edition
ISBN: 9780133970784
Author: Walter Savitch, Kenrick Mock
Publisher: Addison-Wesley
bartleby

Videos

Textbook Question
Book Icon
Chapter 2, Problem 3PP

Suppose you can buy a chocolate bar from the vending machine for $1 each. Inside every chocolate bar is a coupon. You can redeem seven coupons for one chocolate bar from the machine. You would like to know how many chocolate bars you can eat, including those redeemed via coupon, if you have n dollars.

For example, if you have 20 dollars then you can initially buy 20 chocolate bars. This gives you 20 coupons. You can redeem 14 coupons for two additional chocolate bars. These two additional chocolate bars give you two more coupons, so you now have a total of eight coupons. This gives you enough to redeem for one final chocolate bar. As a result you now have 23 chocolate bars and two leftover coupons.

Write a program that inputs the number of dollars and outputs how many chocolate bars you can collect after spending all your money and redeeming as many coupons as possible. Also output the number of leftover coupons. The easiest way to solve this problem is to use a loop.

Blurred answer
Students have asked these similar questions
Suppose we can buy a chocolate bar from the vending machine for $1 each.Inside every chocolate bar is a coupon. We can redeem six coupons for onechocolate bar from the machine. This means that once you have startedbuying chocolate bars from the machine, you always have some coupons.We would like to know how many chocolate bars can be eaten if we startwith N dollars and always redeem coupons if we have enough for an additional chocolate bar.For example, with 6 dollars we could consume 7 chocolate bars afterpurchasing 6 bars giving us 6 coupons and then redeeming the 6 couponsfor one bar. This would leave us with one extra coupon. For 11 dollars, wecould have consumed 13 chocolate bars and still have one coupon left.For 12 dollars, we could have consumed 14 chocolate bars and have twocoupons left.
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…
In this program, you will check whether two dominoes match. Because you can flip a tile, two tiles match if the number on the left or right matches the left or right on the other tile. You should print all matches. First check a direct match, then try flipping tiles. But don’t flip a tile whose left and right numbers are the same. If there is no match, print "No match". For example, with the tiles 1 3 and 4 3, print 1 3 3 4 Three of my tests are failing since there are duplicates of the print results. How would I go about to remove the duplicate?

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole
Java random numbers; Author: Bro code;https://www.youtube.com/watch?v=VMZLPl16P5c;License: Standard YouTube License, CC-BY