Welcome to the CSC Q&A.
Get help and give help!
Write great code!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+7 votes
asked in CSC212_Spring2019 by (817 points)

2 Answers

+2 votes

Have you tried the String.substring method? That's one way you can grab values from a string.

answered by (462 points)
+2 votes

substring is a good idea and you need to see a pattern. Think of it this way, the first 3 characters you need to grab are indexed 0-2 in the string. The second three characters are indexed 3-5.

If you remember, substring(a, b) means that a is the index of the first character up through, but not including the character at index b.

So if the String you are trying to get the substrings from is named sequence, then
sequence.substring(0,3) if the first 3 characters, sequence.substring(3,6) the next three, sequence.substring(6,9) the next three, and so on.

You need to see a pattern in those indices and use a loop to get them all.

answered by (3k points)
...