# I have a simple question.

• ### Question

• I have a problem that i have to calculate the money with the chocolate bar. With this I am suppose to use a loop. The question would be would it be better to use a do while or a For while. I am thinking a do while. If you guys need to see the problem I can post it thats not problem. I guess what the question is what is the difference with do while and For next loop.
Tuesday, March 8, 2011 1:12 PM

• Sounds like a For...Next loop (for each dollar) inside a Do loop (do the calculations until stop). I'm afraid I didn't really understand the rules of the calculation so you might want to re-phrase if possible.
Paul ~~~~ Microsoft MVP (Visual Basic)
• Marked as answer by Wednesday, March 9, 2011 12:26 PM
Tuesday, March 8, 2011 2:13 PM

### All replies

• What is this "chocolate bar" of which you speak? Is this a homework-type problem? Have you tried writing down the steps you would perform if you were solving the problem by hand?

--
Andrew

• Edited by Tuesday, March 8, 2011 1:28 PM spelling
Tuesday, March 8, 2011 1:28 PM
• I am trying to it is just a little bit confusing yes it is a homework type i am not seeking out the answer to the homework i am just trying to start this problem is all.
Tuesday, March 8, 2011 1:38 PM
• A Do loop executes a block of code until a certain condition is satisfied, while a For...Next loop usually executes code for a given number of iterations.

I can't answer which is preferable to your solution since I don't know how it relates to the calculation.

Paul ~~~~ Microsoft MVP (Visual Basic)
Tuesday, March 8, 2011 1:42 PM
• I sat down and trying to write this on paper This is what I have so far.

each chocolate bar = \$1.00

If you have \$20 =20 bars =20 coupons

that means you will have 14 coupons

for two additional bars = 2 coupons

Which that give you a total to redeem 1 final chocolate bar

result = 23 chocolate bars and two left over.

i have to have the input of number of dollars and the output of how many chocolate bars also another output of the cupons. after this i am suppose to use a nested loop to ask if they would like to do it again.

Tuesday, March 8, 2011 1:49 PM
• Sounds like a For...Next loop (for each dollar) inside a Do loop (do the calculations until stop). I'm afraid I didn't really understand the rules of the calculation so you might want to re-phrase if possible.
Paul ~~~~ Microsoft MVP (Visual Basic)
• Marked as answer by Wednesday, March 9, 2011 12:26 PM
Tuesday, March 8, 2011 2:13 PM
• Does anyone know where i can find information on how to use the money with the for next loop...
Tuesday, March 8, 2011 2:55 PM