Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started