Java Help...Again :P

So I've been at this for most of the day today and my mind is starting to hurt.  I'm supposed to program something that follows a puzzle/pattern:

1,4

//there's one 1, and one 4.  so the next line will be:

11,14

//now there's three 1 and one 4.  that means the next line will be:

31,14

21, 13, 14

//and so on.  after a couple runs, you'll see that the program begins to repeat itself in a pattern like a-b-a-b or a-b-c-a-b-c type fashion.

-Requires User Input

-Required to be robust.  I still don't really get the hasnextInt concept, either.

-Required to print at which line it detected a pattern

This is what I have so far.  I'm having a bit of a tantrum trying to figure out how to turn an int into an array(we just learned these)

http://pastebin.com/seYUxdF4

Any help would be highly appreciated.

Handy tip: Instead of using print("xyz") followed by println(), you can just use println("xyz")

As for your main problem, arrays are your friend! Instead of declaring a bunch of ints (a, b, c....etc) just declare an array of them with whatever size you need. You're just counting digits right, so you would just need an array with 10 elements seeing as how there's only 10 digits. Then each array index maps to the count for a specific number. Then, all you need to do is something like:

int[] counts = new Int[10];

for (int i = 0; i < numIn.length; i++) {

   int num = numIn[i];

   count[num - 1] += 1;

}

for (int i = 0; i < 10; i++) {

    System.out.println((i + 1) + "" + count[i] + ",");

}

 

That doesn't cover how to detect the pattern, but it hopefully gives you an idea of how to use arrays. Also, just a quick concepty thing. An array is a list, an int is an item. Don't think of it as converting an int to an array. You can either insert the int into an array, or make a new array with the int as its only item.

Hope something there helps you, let us know if you need more help and I suggest googling arrays if you're not familiar with the concept. They will become your best friend, I promise!

EDIT: Also, I may be going crazy, but isn't your reference to numIn in the Pattern function throwing an error? I would have thought it would be out of scope but I haven't done much java in a while so I could be wrong :)

Thanks, that really helped a lot.

numIn isn't out of scope as nothing's really being inputted into the array.  It's just full of zeroes as I try to figure out an input method so I can store numbers in the array.