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 6 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:

1. With 6 dollars a person could buy 7 chocolate bars after purchasing 6 bars giving him/her 6 coupons and then redeeming the 6 coupons for one bar. This would leave him/her with one extra coupon.

2. For 11 dollars, a person can have 13 chocolate bars and still have one coupon left.

3. For 12 dollars, a person can have 14 chocolate bars and have two coupons left.

Write a complete Java 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.

Note:

Use a loop that continues to redeem coupons as long as there are enough to get at least one chocolate bar.

Sample program run:

Use the sample run below to check the correctness of your program. Your program must use the exact text for prompting and output display. Using the given input values for the prompts, your program must display the output provided:

Sample 1:

How much money can you spend on chocolate bars?
56
After redeeming coupons, you would have 1 leftover coupons and can purchase a total of 67
chocolate bars.

Sample 2:

How much money can you spend on chocolate bars?
7
After redeeming coupons, you would have 2 leftover coupons and can purchase a total of 8
chocolate bars.
Academic Honesty!
It is not our intention to break the school's academic policy. Posted solutions are meant to be used as a reference and should not be submitted as is. We are not held liable for any misuse of the solutions. Please see the frequently asked questions page for further questions and inquiries.
Kindly complete the form. Please provide a valid email address and we will get back to you within 24 hours. Payment is through PayPal, Buy me a Coffee or Cryptocurrency. We are a nonprofit organization however we need funds to keep this organization operating and to be able to complete our research and development projects.