[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y ] [Search | Free Show | Home]

Intro Programming Class Help

This is a blue board which means that it's for everybody (Safe For Work content only). If you see any adult content, please report it.

Thread replies: 7
Thread images: 3

File: IMAG0171 (1).jpg (646KB, 2296x4096px) Image search: [Google]
IMAG0171 (1).jpg
646KB, 2296x4096px
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.
>>
File: IMAG0168.jpg (2MB, 4224x2368px) Image search: [Google]
IMAG0168.jpg
2MB, 4224x2368px
so far this is what I've written.
>>
File: IMAG0166_1.jpg (27KB, 638x314px) Image search: [Google]
IMAG0166_1.jpg
27KB, 638x314px
>>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);
Thread posts: 7
Thread images: 3


[Boards: 3 / a / aco / adv / an / asp / b / bant / biz / c / can / cgl / ck / cm / co / cock / d / diy / e / fa / fap / fit / fitlit / g / gd / gif / h / hc / his / hm / hr / i / ic / int / jp / k / lgbt / lit / m / mlp / mlpol / mo / mtv / mu / n / news / o / out / outsoc / p / po / pol / qa / qst / r / r9k / s / s4s / sci / soc / sp / spa / t / tg / toy / trash / trv / tv / u / v / vg / vint / vip / vp / vr / w / wg / wsg / wsr / x / y] [Search | Top | Home]

I'm aware that Imgur.com will stop allowing adult images since 15th of May. I'm taking actions to backup as much data as possible.
Read more on this topic here - https://archived.moe/talk/thread/1694/


If you need a post removed click on it's [Report] button and follow the instruction.
DMCA Content Takedown via dmca.com
All images are hosted on imgur.com.
If you like this website please support us by donating with Bitcoins at 16mKtbZiwW52BLkibtCr8jUg2KVUMTxVQ5
All trademarks and copyrights on this page are owned by their respective parties.
Images uploaded are the responsibility of the Poster. Comments are owned by the Poster.
This is a 4chan archive - all of the content originated from that site.
This means that RandomArchive shows their content, archived.
If you need information for a Poster - contact them.