Question on substring division and sorting to arrays

• 11-13-2013, 02:31 AM
Thurokiir
Question on substring division and sorting to arrays
Currently working on the bog-standard Meyers-Briggs array project.

I have the idea of taking the string of 70 inputs and slicing them down via a substring. The substring divider part, I think I have done correctly, however my sticking point is taking that substring and sorting it's 7 input values to one of four arrays, I'm not entirely sure of how to do this.

My current work on my "sectionCutter" is rough starting at line 19 but, thus:

Code:

```public class sectionCutter {         public static void sectionCutter(String[] args){                 String results = "BABAAAABAAAAAAABAAAABBAAAAAABAAAABABAABAAABABABAABAAAAAABAAAAAABAAAAAA";                 int i = 0;                 int s = 0;                 char[] EvsI = new char[10];                 char[] SvsN = new char[20];                 char[] TvsF = new char[20];                 char[] JvsP = new char[20];                 while(i < results.length());{                         String divider = results.substring(i, i + 7);                         System.out.println(divider);                         i += 7;                         divider.charAt(i);                                                             for(s > divider.length(); s++){                                         if(s){                                                 }                                         if(int s = 1){}                                         if(int s = 2,3){}                                         if(int s = 4,5){}                                         if(int s = 6,7){}                                         if(divider.charAt(s)){                                                                                         }                                 }                                         }         } }```
The most ideal help would just be the syntax for an iterator that counts and then sorts to different arrays, I've been enjoying the exercise so far but this idea for how I want to implement the "sorter" is totally kicking my ass.

- Many thanks, Thurokiir
• 11-13-2013, 03:51 AM
Norm
Re: Question on substring division and sorting to arrays
Quote:

counts and then sorts to different arrays
Can you explain what is to be counted and how the Strings are to be sorted and stored in the different arrays?
• 11-13-2013, 04:03 AM
Thurokiir
Re: Question on substring division and sorting to arrays
Quote:

Originally Posted by Norm
Can you explain what is to be counted and how the Strings are to be sorted and stored in the different arrays?

Certainly!

I'm given a long string of user inputs to multiple choice questions:
bbbaaabbbbaaba-BAAAABBABBAAABBAABAAB-AAAAABBBABAABABA-ABBBABBABAA-AAAA
These multiple choice questions are always in the same order in respect to one of four question categories:
1223344

The original string is 70 characters long, the multiple choice pattern is in sets of 7. So my plan in so far is to process the long string into chunks of 7 via a while loop substring. I THINK I have that down, the hard part at the moment for me is to send the 7 user inputs that I have gathered via my substring method and send them back to one of four arrays.

Does that clear anything up?
• 11-13-2013, 04:18 AM
Norm
Re: Question on substring division and sorting to arrays
The question I was asking was: what is to be done with the group of 7 character Strings? You mention counting and sorting? What is counted and how are they sorted?
• 11-13-2013, 04:30 AM
Thurokiir
Re: Question on substring division and sorting to arrays
Each group of seven follows a pattern of what arrays I want to send the values to, 1 22 33 44. I want to iterate through the group of seven then as I count each value, I want to send that value to an array.

Currently I have a guess of
if(s = 1){
then(System.out.println(String.toArray(EvsI));

I think that does what I want, sends the character value of when S = 1 to the Array EvsI. I'm not totally sure though, the syntax is eluding me pretty hard here.
• 11-13-2013, 04:49 AM
Norm
Re: Question on substring division and sorting to arrays
Quote:

the syntax is eluding me
Are you having problems with coding an if statement? Take a look at the tutorial:
The if-then and if-then-else Statements (The Java™ Tutorials > Learning the Java Language > Language Basics)
• 11-13-2013, 05:05 AM
Thurokiir
Re: Question on substring division and sorting to arrays
The if statement is not my big issue, it is identifying a letter within each substring iteration and sending it to a corresponding array based on the 1223344 pattern.
• 11-13-2013, 01:41 PM
Norm
Re: Question on substring division and sorting to arrays
Quote:

identifying a letter within each substring iteration and sending it to a corresponding array based on the 1223344 pattern.
What are the rules for that? How is a letter identified and what array corresponds to it? How is the 1223344 pattern used?
• 11-13-2013, 01:50 PM
jim829
Re: Question on substring division and sorting to arrays
I have been following this thread and I still don't understand the problem. Are a's and b's the answers to questions? Are A's and a's the same -- see item #3. What is the significance of 1223344? Does 1,22,33,and 44 identify one of the four arrays? If so, why those particular numbers and not 1,2,3, and 4? And why are three of your arrays of size 20 and the first is of size 10? For use to help you it really helps us to understand the requirements of the problem.

Regards,
Jim