Java help needed.


Recommended Posts

Use a for loop within a for loop. The inner loop prints the number of asterisks in the row, then the outer loop moves everything to the next line. Run that double loop for the intended length of the pattern (number of lines it runs), divided by two. Then have another double loop with does the same thing but just counts down asterisks instead of up.

Link to post
Share on other sites
10 minutes ago, FOX545 said:

Use a for loop within a for loop. The inner loop prints the number of asterisks in the row, then the outer loop moves everything to the next line. Run that double loop for the intended length of the pattern (number of lines it runs), divided by two. Then have another double loop with does the same thing but just counts down asterisks instead of up.

Yeah that was kinda obvious, but I'm just not getting it right. I've been trying over and over again and just don't know where I'm going wrong. 

Link to post
Share on other sites
5 hours ago, Chaos said:

Yeah that was kinda obvious, but I'm just not getting it right. I've been trying over and over again and just don't know where I'm going wrong. 

Try using the debugger if your IDE has one

 

If not you could just copy your code here and we could try to help

Edited by FOX545
Link to post
Share on other sites
2 minutes ago, Chaos said:

Ok nvm I got that. Someone explain Binary search to me instead plox

Binary search is a common but very powerful algorithm used to increase the efficiency of your programs. To have an idea of how binary search works, think of it in this way: Suppose you were asked to think of a number between 0-100 and I had to guess what number you had. If I used the binary method, I'd guess 50. Then you'd tell me whether I'm right or if I'm guessing too high or too low. If I'm right, I'll stop and say 50 is the right answer. If I'm too high, I'll limit my guesses from 0 to 49. If I'm too low, it'll reduce to 51-100. You keep going till you get the right answer. You can see that this reduces the number of guesses drastically. 

Link to post
Share on other sites
3 minutes ago, Master Flap said:

Binary search is a common but very powerful algorithm used to increase the efficiency of your programs. To have an idea of how binary search works, think of it in this way: Suppose you were asked to think of a number between 0-100 and I had to guess what number you had. If I used the binary method, I'd guess 50. Then you'd tell me whether I'm right or if I'm guessing too high or too low. If I'm right, I'll stop and say 50 is the right answer. If I'm too high, I'll limit my guesses from 0 to 49. If I'm too low, it'll reduce to 51-100. You keep going till you get the right answer. You can see that this reduces the number of guesses drastically. 

Any programs to serve as examples?

Link to post
Share on other sites
48 minutes ago, Jade Maveric said:

Try the binary search tutorial on KhanAcademy.

And can someone please clarify, are links allowed?

They are, unless they conflict with the rules (there is no longer an external link rule). The only rule that can by bypassed somehow is swearing, which can be done in PM if both parties are comfortable with it and you could post a video or link with swearing in it, making sure to warn the viewers.

Or at least that is what I believe.

Edited by Chocozeus
Italicizing
Link to post
Share on other sites
  • 1 year later...
  • 8 months later...
On 2/12/2016 at 0:55 PM, Master Flap said:

Tons. Many programs use it. Using a slightly modified version of it, there are programs that find square roots of numbers.

Other examples are of course, guessing games. 

can you send me a link of those programs? That sounds interesting.

Link to post
Share on other sites
1 hour ago, Agent P said:

can you send me a link of those programs? That sounds interesting.

:P I'll search for it. Though I've only seen it on a friend's computer once. XD 

Wow, wasn't hard to find it. https://www.geeksforgeeks.org/square-root-of-an-integer/

I haven't checked it thoroughly but that's what I was talking about. 

Link to post
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.