I am brand new to Java and I am taking an introductory programming course. We have to create the following output with nested loops. I am trying but I have no idea what's going on with half of this stuff.
Here's the ouput I need:
0123456789
12345678910
234567891011
3456789101112
45678910111213
567891011121314
6789101112131415
78910111213141516
891011121314151617
9101112131415161718
Here's my disastrous code:
public class forLoopTest
{
public static void main(String[] args)
{
for (int i=0; i <=9; i++)
{
for (int k=i; k <18; k++)
{
System.out.println(k);
}
}
System.out.println();
}
}
Any help would be greatly appreciated. E.g. tell me what I am doing wrong, how to fix it...
Edited by Roger, 15 February 2012 - 08:56 AM.
moved to correct forum and added code tags


Sign In
Create Account

Back to top









