Hi i am supposed to write a code in java which will have as an input a tree.
Here is my code ( needs to have 3 args):
public class Tree
{
public static void main(String[] args)
{
int H = Integer.parseInt(args[0]);
int n = Integer.parseInt(args[1]);
int h = Integer.parseInt(args[2]);
String a = "A";
while (n > 0)
{
while (H > 0)
{
System.out.println(a);
a = "A" + a + "A";
H -= 1;
}
H = Integer.parseInt(args[0]);
a = a.substring(2, a.length() - 2);
n -= 1;
}
}
}
Here is the result:
A
AAA
AAAAA
AAAAAAA
AAAAA
AAAAAAA
AAAAAAAAA
AAAAAAAAAAA
AAAAAAAAA
AAAAAAAAAAA
AAAAAAAAAAAAA
AAAAAAAAAAAAAAA
I want to know what should i do to make it straight.