Hey guys, i got an assignment to write a java program that takes a command line argument (N) and creates a checkerBox like the one below if N is 5 :
* * * * *
* * * * *
* * * * *
* * * * *
* * * * *
Pleas notice the small detail that first line starts with a "*" and the second with a space, and so on ...
Till now, i have managed to write the folowing :
public class checkerboard
{
public static void main(String[] args)
{
int n = Integer.parseInt(args[0]);
int i;
for (i = 1; i<= n; i = i + 1)
{
System.out.print("* ");
}
System.out.println();
for (i = 1; i <= n; i = i + 1)
{
System.out.print(" *");
}
}
}
What this does is that it prints "*" N number of times, but only 2 lines, and not as many lines as N ... i am new to java and kinda stuck ... please, someone help ... ANYONE :D