Hi ,

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.

#include<iostream>

using namespace std;

int main()

{

int money,n;

int s,finish;

cout<<" Enter the total amount of money ";

cin>>money;

do

{

s=(money/7)+(money%7);

n=money+(money/7);

}

while(s<7);

cout<< "bar "<<n;

cout<<endl;

cin>>finish;// keep the output window open

return 0;

}

Do you have an idea?

Thank you

B