java - for loop inside while loop using if condition -


i'm little bit confused homework assignment i'm working on. i'm trying write 7 sets of 123. except when number of set don't want write 123 word , no numbers , move on next set.
im using while loop keep track of counting sets , loop counting 123. problem program written prints continuously.
tried putting if condition inside loop continuously prints (123 even) forever.
incorrectly applying if condition? incorrectly applying condition?

import acm.program.*; public class testprogram extends consoleprogram {      public void run()     {         int = 1;          while (i <= 7)         {             if (i % 2 == 0)             {                 println("even");             }             else             {                 (int j = 1; j <= 3; j++)                 {                     println(j);                 }             }         }     }  } 

you're not incrementing @ all, it'll never terminate. after statement, add like

i++; 

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -