![]() |
count multiples of 6 between two numbers given by the user.
Hi all, Is my answer true .. and I want your opinion in my answer
• Write a program fragment to count multiples of 6 between two numbers given by the user. :
Thank you.. |
Re: count multiples of 6 between two numbers given by the user.
I think you got it. Quick note though, the two number (X and Y) should be inputted by the user, not you, so you should probably ask for them.
|
Re: count multiples of 6 between two numbers given by the user.
Your logic is not quite correct. Try X=35, Y=35 or X=42, Y=48.
Hint: Use a while loop instead of a do/while loop. The latter should be avoided when possible. (There is another problem with your code, but I will let you figure out what it is.) |
Re: count multiples of 6 between two numbers given by the user.
i pointed this out to him in his other post, as it was a very similar problem and he made the very same logically mistake as he has done here.
|
Re: count multiples of 6 between two numbers given by the user.
I have a tip; don't make it so obvious that you are doing homework problems. Goodness.
|
Re: count multiples of 6 between two numbers given by the user.
I agree with titaniumdecoy...don't use a do...while loop. Use a while loop (or I suppose a for loop would work in this case as well). Also, have X and Y be input. You could use a scanner or you could use a JOptionPane. Also, why do you increment X before you check to see if it's a multiple of six?
|
| All times are GMT -5. The time now is 1:18 AM. |
Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC