Question: How can I alter this Java method so that I convert and then return every sentence in the array of strings instead of just the

How can I alter this Java method so that I convert and then return every sentence in the array of strings instead of just the first sentence?

public static char[] charConvert ( String [] sentences ) { int totLength = sentences[0].length() + sentences[1].length() + sentences[2].length() + sentences[3].length() + sentences[4].length(); char [] letter = new char[totLength]; int x = 0; int y = 0; while ( y < sentences[x].length() ) { switch ( sentences[x].charAt(y) ) { case 'a': case 'A': letter[y] = 'N'; break;

case 'b': case 'B': letter[y] = 'O'; break;

case 'c': case 'C': letter[y] = 'P'; break;

case 'd': case 'D': letter[y] = 'Q';

default: break; } y++; }

public static char[] charConvert ( String [] sentences ) { int totLength = sentences[0].length() + sentences[1].length() + sentences[2].length() + sentences[3].length() + sentences[4].length(); char [] letter = new char[totLength]; int x = 0; int y = 0; while ( y < sentences[x].length() ) { switch ( sentences[x].charAt(y) ) { case 'a': case 'A': letter[y] = 'N'; break;

case 'b': case 'B': letter[y] = 'O'; break;

case 'c': case 'C': letter[y] = 'P'; break;

case 'd': case 'D': letter[y] = 'Q';

default: break; } y++; }

return letter;

}

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!