Charlie Hauk wrote:Would appreciate any help that I can get.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Charlie Hauk wrote:Would appreciate any help that I can get.
Well, just off the top of my head, I'm wondering what:
int end[] = new int[intfinish - 1];
is for.
Simply put: it's wrong (well OK, not necessarily wrong; but certainly overcomplicated) - but I was wondering why you thought you needed to do it.
Winston
Charlie Hauk wrote:It took the finish value that the user inputs (2-50) and stubtracts one since the arrays start at 0.
So for example, if they entered a finish value of 12, we need 11 cells in the array.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Campbell Ritchie wrote:Did you have difficulty writing that loop?
Winston Gutkowski wrote:And doing it your way, you'll be forced to adjust all the index values you use.
Tip: The simplest way (providing it works) is almost always the best.
Charlie Hauk wrote:But as far as the simplest way, this is the first thing that came to my head.
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:No, the length came into your head. But what about when you come to access those values? (which you're likely to do a lot more than setting up the array)
For a times table for x, wouldn't it be a lot easier to simply have the value for x*n in table[n]?
OK, you probably won't use table[0] or table[1] very often, but does that matter? Memory is cheap, and you can certainly plug in values that make sense, even for those entries.
It does mean that you have to consider that index 0 when calculating the length, however; but I'll leave that up to you.
Winston
Charlie Hauk wrote:Oh... I see now. See, I misunderstood the arrays I guess. I was thinking that they HAD to start on the 0 cell. DERP!
"Leadership is nature's way of removing morons from the productive flow" - Dogbert
Articles by Winston can be found here
Winston Gutkowski wrote:
Charlie Hauk wrote:Oh... I see now. See, I misunderstood the arrays I guess. I was thinking that they HAD to start on the 0 cell. DERP!
They do. But there's no God-written rule that says that you have to USE all those cells.
Winston
Campbell Ritchie wrote:At least two ways to do it:
1: Use a loop 2: Find methods of this class which can turn an int[] into a String. Because arrays don’t have overridden toString() methods, you can’t simply write system.out.println(myArray);
There is something strange about your loop with 2 and index - 2 in. Did you have difficulty writing that loop?
Campbell Ritchie wrote:You have got some poorly‑named identifiers there, including the name of the method. That does not print an array, but only part of it. And what is going to happen if I do this:-What is more, you cannot put that on a component of any kind. That method does not do what you want at all.
You were right to look for a toString method, so you need to use some sort of toString method. Do you have to write your own, or can you look for a utility class which might have such a method ready‑made?