Taking a programming class and I have no experience with the subject. Have this assignment due in a couple of days and I just started working on it. I need to write a java program that will print the pattern in the featured image of this thread.
so far this is what I've written.
>>278434
which prints this;
My current plan is to write a "top" method and a "bottom" method that are each called upon once in the main method. But I'm having trouble understanding how to repeat the symbols I've already created into another line with indented spaces and fewer spaces in between the 2 main symbols. ALSO: THE CLASS CONSTANT IS 3
>>278433
I could be wrong, but it seems there is a problem with your annotations, because on the first line the middle space is 5 long, but on the second line the "++ ++", which is just under the middle space, is 6 long.
>>278448
Oh shit, youre right. Good catch, ill fix that easy.
Top part is actually 6 spaces.
You need to make two helper functions to start:
drawTopSymbol(int spacesInbetween)
drawBottomSymbol(int spacesInbetween)
Figure it out. Here's the first thirdof drawTopSymbol:
print("++");
for(int i=0; i<spacesInbetween; i++)
print(" ");
print("++");
println();
Next is the main function:
I'll call the variable XDiagonalHalfLength which is 3 in the top image.
For the top part, loop from 2 to 0:
for (int i = XDiagonalHalfLength - 1, i--, i==0)
drawTopSymbol(XDiagonalHalfLength * 2);
For the bottom part, loop from 0 to 2:
for (int i = 0, i++, i==XDiagonalHalfLength - 1)
drawBottomSymbol(XDiagonalHalfLength * 2);