I have this problem I need to code in C++:
we want to know how many candies you can have with a certain amonut of money.
Each candy costs $1 and at each candy purchase, you receive 1 coupon.
You can redeem 1 candy with 7 coupons.
If you have $20, you can have 23 candies.
20/7=2 more candies from the coupons=2 more coupons.
then 20%7=6 coupons remain.
6+2=8 coupons with which you can have 1 candy.
So 20+2+1=23 candies in total.
I try to use the modulo ("%") but still I cannot find the answer. Iwant to use a loop.
this what I did. I found 22 bars instead of 23.
using namespace std;
cout<<" Enter the total amount of money ";
cout<< "bar "<<n;
cin>>finish;// keep the output window open
Do you have an idea?