Question: 5. Write the method charBlock using the header below that takes a string s and integers r and c as parameters and returns the characters

 5. Write the method charBlock using the header below that takes

5. Write the method charBlock using the header below that takes a string s and integers r and c as parameters and returns the characters of s arranged in a 2D array with r rows and c columns. As you read across the rows of the 2D array, the characters of s should appear in their original order. For example, the method call charBlock ("Hello world", 3, 4) should return [[ 'H', e ['o', ['r', 'l' 'l', 'l', 'w' So'], ] 'd', As you can see in the example, the characters of "Hello world" have been arranged in a 2D array with three rows and four columns. You may assume that r and c will allow enough rows and columns to store all of the character of s. Any extra cells on the right side of the bottom row of the 2D array should be assigned the space character, such as in location [2] [3] above. String method you will probably find useful: charAt(i) //returns the character at index i of the string You may also use other String methods from the AP Quick Reference as necessary. public static char[] [] charBlock (String s, int r, int c) {

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!