Results 1 to 9 of 9
  1. #1
    Thurokiir is offline Member
    Join Date
    Nov 2013
    Posts
    4
    Rep Power
    0

    Default 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:

    Java 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
    Last edited by Thurokiir; 11-13-2013 at 04:05 AM. Reason: Updating Syntax

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: Question on substring division and sorting to arrays

    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?
    If you don't understand my response, don't ignore it, ask a question.

  3. #3
    Thurokiir is offline Member
    Join Date
    Nov 2013
    Posts
    4
    Rep Power
    0

    Default Re: Question on substring division and sorting to arrays

    Quote Originally Posted by Norm View Post
    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?
    Last edited by Thurokiir; 11-13-2013 at 03:03 AM. Reason: Clarity

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default 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?
    If you don't understand my response, don't ignore it, ask a question.

  5. #5
    Thurokiir is offline Member
    Join Date
    Nov 2013
    Posts
    4
    Rep Power
    0

    Default 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.
    Last edited by Thurokiir; 11-13-2013 at 03:39 AM. Reason: Also answering a question.

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: Question on substring division and sorting to arrays

    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)
    If you don't understand my response, don't ignore it, ask a question.

  7. #7
    Thurokiir is offline Member
    Join Date
    Nov 2013
    Posts
    4
    Rep Power
    0

    Default 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.

  8. #8
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,306
    Rep Power
    25

    Default Re: Question on substring division and sorting to arrays

    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?
    If you don't understand my response, don't ignore it, ask a question.

  9. #9
    jim829 is offline Senior Member
    Join Date
    Jan 2013
    Location
    Northern Virginia, United States
    Posts
    3,414
    Rep Power
    5

    Default 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
    The Java™ Tutorial | SSCCE | Java Naming Conventions
    Poor planning our your part does not constitute an emergency on my part.

Similar Threads

  1. Sorting arrays
    By Blondedude092 in forum New To Java
    Replies: 2
    Last Post: 12-01-2012, 01:57 AM
  2. Implementing Sorting in Arrays Question
    By jakaldama in forum New To Java
    Replies: 2
    Last Post: 10-10-2011, 08:49 PM
  3. Sorting a String array based on a substring
    By jonytek in forum New To Java
    Replies: 1
    Last Post: 06-07-2011, 06:21 AM
  4. Help with sorting arrays
    By Joycey in forum New To Java
    Replies: 4
    Last Post: 03-30-2010, 08:35 PM
  5. Arrays.sort... why sorting all arrays in class?
    By innspiron in forum New To Java
    Replies: 6
    Last Post: 03-23-2010, 01:40 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •