NEED HELP WITH A QUESTION OF LOOPS

closed account (G6CRDjzh)
HEYY EVERYONE I HAVE AN ASSIGNMENT TO SUBMIT RELATED TO LOOPS AND I HAVE NO CLUE HOW TO SOLVE IT
IF SOME ONE CAN HELP THAT WILL BE REALLY GREAT

Suppose we can buy a juice can from the vending machine for 3 dirhams each. On every purchase of a can of
juice, there is a free coupon. We can redeem 4 coupons for one juice can from the machine. We would like
to know how many juice cans can be consumed, including those redeemed via coupons, if we have n
dirhams.
For example, if we have 20 dirhams then we can initially buy 6 cans of juice. This gives us 6 coupons. We can
redeem 4 coupons for 1 additional can of juice. This one additional can of juice adds one more coupon, so we
now have a total of 3 coupons when added to the 2 leftover from the original purchase. As a result we now
have 7 cans of juice and 3 leftover coupons.
Write a program that inputs the purchase amount of dirhams and outputs how many juice cans you can
collect after spending all your money and redeeming as many coupons as possible. Also output the number
of leftover coupons.
Hint: Use a while loop that redeems coupons for juice and calculates the new number of coupons. Continue
the loop as long as you have enough coupons to redeem for juice.
What kind of help do you need? About while loops? How to use a counter?
Please post on what you have done so far and what problems are you having?

http://www.cplusplus.com/forum/articles/40071/#msg218019

Good luck
Last edited on
closed account (48T7M4Gy)
Write a program that:

1. inputs the purchase amount of dirhams
and
2. outputs how many juice cans you can collect after spending all your money and redeeming as many coupons as possible.
Also
3. output the number of leftover coupons.
Topic archived. No new replies allowed.