So they forced me to take java despite having no programming background... I'm a web design major, not programming. Anyway, I'm really stuck on the homework problem - if anyone could help me out that would be amazing. I need to write a program (using a loops) so that the output is:

00222444466666888888
00222444466666888888

I know it doesn't look that hard but I'm really lost with this stuff.
Thanks,
Mikey

We really do want to help, but you have to show some effort before we do that. Post the code you have using code tags so we can make corrections and help guide you. We are not here to just do your homework for you.

here you go

for(int eventNumber = 0; evenNumber < 10; evenNumber+= 2){
   for(int times = 2; times < 7; times++){
        System.out.print(envenNumber);
   }
}

Thanks a lot ejosiah. That was the only problem giving me trouble, I really appreciate it.

anytime bro :-)

correction There is a mistake in the code above. use this instead

int printTimes = 2;
for(int eventNumber = 0; evenNumber < 10; evenNumber+= 2){
    for(int i = 0; i < printTimes; i++){
          System.out.print(envenNumber);
          printTimes++;
    }
}

The first code prints each number 7 times and thats not what you want the correct version (2nd) print the first number twice and then processed and increments the print by one for each subsequent number and thats what you want. So now you should be able to explain the code.

guess its not my day today made another mistake. The second code is much worse than the first one and never stops printing.The next code should be write. Please do test it to make sure it works as you expect and don't just hand it in

int printTimes = 2;
for(int eventNumber = 0; evenNumber < 10; evenNumber+= 2){
      for(int i = 0; i < printTimes; i++){
           System.out.print(envenNumber);
      }
     // increment print times for next number
     printTimes++;  
}

It should be fine now. don't forget to give it a test run

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.