954,510 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Help with java code for counting numbers by 2, 3 ,4, and so on

I am needing to write a program for someone that needs it to count by any number they manually enter into the program. I have the menu code written and now just need help with the counnting code. I know i most likely need to use a "for" loop but after that i am not sure.

fireballthor
Newbie Poster
2 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

so, if I input 5 it should count 5,10,15,20,25 or 1,2,3,4,5 ?

Nichito
Posting Virtuoso
1,602 posts since Mar 2007
Reputation Points: 424
Solved Threads: 57
 

yes 5 10 15 20 and soo on

fireballthor
Newbie Poster
2 posts since Mar 2011
Reputation Points: 10
Solved Threads: 0
 

that's easy just put while loop that has a number in it then print the number then put an empty for loop and then add 5 to the number then repaint/ redraw the number and continue. it should look something like this:

int a = 0;
while (a == 0){
int num = 0;
for (int i = 0; i <= enter a number here that suits your delay; i++);
num += userEnteredNumber;
//repaint/set text etc.
}


Hope I hepled

sirlink99
Practically a Master Poster
661 posts since Oct 2010
Reputation Points: 45
Solved Threads: 19
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You
View similar articles that have also been tagged: