# Thread: Good ol' arrays! Help O_O

1. Member
Join Date
Nov 2011
Posts
6
Rep Power
0

## Good ol' arrays! Help O_O

Okay guys... I'm in my only CS class I have to take and I'm almost done and barely keeping my head above the programming water!
So here's my assignment:
Proff. gave us a file to download and input into the java program (got that :)) and in there are names of 'people' who have taken a Meyers-Briggs personality test and their answers (either A, B, or if they left it blank a -). So it comes in format like this:
Name Here: Bababbbaaaa-AAbaabab until 70 questions of the test are completed. This is how the questions roll:
(1) Extrovert versus Introvert (E vs. I): what energizes you
(2) Sensation versus iNtuition (S vs. N): what you focus on
(3) Thinking versus Feeling (T vs. F): how you interpret what you focus on
(4) Judging versus Perceiving (J vs. P): how you approach life

And the set-up for the arrays is like this:
(1) The first one question is an Introvert/Extrovert question (questions 1, 8, 15...).
(2) The next two questions are for Sensing/iNtuition (questions 2 and 3, 9 and 10...).
(3) The next two questions are for Thinking/Feeling (questions 4 and 5, 11 and 12...).
(4) The next two questions are for Judging/Perceiving (questions 6 and 7, 13 and 14...).

AKA:

dimension 1223344 1223344 1223344 1223344 1223344 1223344 1223344 1223344 1223344 1223344
char BABAAAA BAAAAAA ABAAAAB BAAAAAA BAAAABA BAABAAA BABABAA BAAAAAA BAAAAAA BAAAAAA

My job is to take all of that gibberish and put it into an output that shows how many A's and B's comparatively in each category (the 1,2,3 and 4 categories) so the format comes out like this:
Betty Boop:
<-- this is what I'm having the most problems with!
percent B: [90, 15, 10, 10] <-- this is the percentage of B's compared to A's

type: ISTJ <-- with percent of B's, this is their personality.

So.. here's my code. If you guys come up with a fix for my problem, that would be great. I'm SO not asking you all to do the rest of it for me, just to help me get the 'answers' format correct. If you guys need the file reference, I can email it to you.
Here's my code (and if you can get it less redundant, I would also appreciate that because she's gonna dock points for redundancy lol)

[ Code removed by request of the course instructor ]
Last edited by JosAH; 06-16-2014 at 10:04 AM. Reason: code tags added

2. ## Re: Good ol' arrays! Help O_O

No it is not readable. Do not use coloured text. When posting code use code tags. Place [ code ] before and [ /code ] (without the spaces) after your code. If you get any errors post them. Ask a specific question. Do not embed the question in the code, post it before or after.

3. ## Re: Good ol' arrays! Help O_O

I have edited your post and have added [code] and [/code] above and below your post. I second all that Junky had to say. Please try to formulate as specific a set of questions as possible, otherwise we'll have little choice but to simply refer you to the tutorials.

4. ## Re: Good ol' arrays! Help O_O

Why is there a winking smilie in the middle of my post?

5. ## Re: Good ol' arrays! Help O_O

Originally Posted by Junky
Why is there a winking smilie in the middle of my post?
Perhaps you've gone soft on us?

6. ## Re: Good ol' arrays! Help O_O

Originally Posted by Junky
Why is there a winking smilie in the middle of my post?
Stoopid browser not refreshing properly!

7. Member
Join Date
Nov 2011
Posts
6
Rep Power
0

## Re: Good ol' arrays! Help O_O

Okay.. so any ideas? Thanks for editing it btw, but do we have a code fixer or no?

8. ## Re: Good ol' arrays! Help O_O

I have plenty of ideas. If you would like a specific one then ask a specific question.

9. Member
Join Date
Nov 2011
Posts
6
Rep Power
0

## Re: Good ol' arrays! Help O_O

Okay so you all need a more specific question... So I said up there the format of the file I'm importing and how I have to use the 'answers' to output it in a different way. each string of seven 'answers' Ex: ABAAbab is a 'set' and will restart with the different type of question (an extrovert/introvert) in an array patter such as this: 1223344. There are seventy questions so there are 10 sets of these tiny sets. I need to add ALL of the 1's (a's and b's seperately) ALL of the 2's (a's and b's separately) and so on to be able to compare the a answers and b answers of the different types of questions throughout the whole questionaire. It's confusing but not really... just read it a couple times.
I'm just having problems getting the arrray set up so that it makes groups of seven and loops through the groups of seven to count all of the similar items (all the 1's, 2's etc.).
Thanks

10. ## Re: Good ol' arrays! Help O_O

Why do you need an array? Just use a loop to and substring to get a block of seven chars at a time. Then you can read those seven chars individually and update some variables. At the end of all the reading you have some math to perform which is exactly the same in any programming language as well as on paper.

11. Member
Join Date
Nov 2011
Posts
6
Rep Power
0

## Re: Good ol' arrays! Help O_O

Well, that was my 'intention' with the mess of for loops up there which obviously didn't work but I think should, there's probably just a curly bracket in the wrong place. I'm actually not even sure why it's not counting right... it's counting that EVERYTHING is a B or an A, which is odd... but I'm still using the arrays up there. I guess I'm not too sure what you're getting at by making a block w/o the arrays to make such a block.

12. ## Re: Good ol' arrays! Help O_O

Java Code:
```public class Test {
public static void main(String[] args) {
String text = "ABBBAAABABABABAAABBBB";
int start = 0;
int aCount = 0;
int bCount = 0;
while(start < text.length()) {
String subset = text.substring(start, start + 7);
System.out.println(subset);
start += 7;
if(subset.charAt(0) == 'A') {
aCount++;
} else {
bCount++;
}
}
System.out.println(aCount);
System.out.println(bCount);
}
}```
A rough idea what needs to be done. You should be able to build on it.

13. Member
Join Date
Nov 2011
Posts
6
Rep Power
0

## Re: Good ol' arrays! Help O_O

So it's kindof working and I get the idea, but it wont let me 'scan' the line and get info from the line, it only allows the input at the String text = "blahblahblah";... I tried putting in another scanner but it doesn't come out with any results.

14. Member
Join Date
Nov 2011
Posts
6
Rep Power
0

## Re: Good ol' arrays! Help O_O

HAHA! Success! Oh wow, thanks so much! I hope you feel good helping noobs, because you're great at it lol!

#### Posting Permissions

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