Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

What I want to do next inside this Java method is make sure the characters are returned in 5 letter chunks. Am having some trouble

What I want to do next inside this Java method is make sure the characters are returned in 5 letter chunks. Am having some trouble with the code and getting it to display properly. For example, I need "abcdefghijklmnop" to return as " nopqr stuvw xyzab c"

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 y = 0; int z = 0; for ( int i = 0; i < sentences.length; i++ ) { String str = sentences[i]; z = 0; while ( y < totLength && z < str.length() ) { switch ( str.charAt(z)) { 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'; break;

case 'e': case 'E': letter[y] = 'R'; break;

case 'f': case 'F': letter[y] = 'S'; break;

case 'g': case 'G': letter[y] = 'T'; break;

case 'h': case 'H': letter[y] = 'U'; break;

case 'i': case 'I': letter[y] = 'V'; break;

case 'j': case 'J': letter[y] = 'W'; break;

case 'k': case 'K': letter[y] = 'X'; break;

case 'l': case 'L': letter[y] = 'Y'; break;

case 'm': case 'M': letter[y] = 'Z'; break; case 'n': case 'N': letter[y] = 'A'; break;

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

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

case 'q': case 'Q': letter[y] = 'D'; break;

case 'r': case 'R': letter[y] = 'E'; break;

case 's': case 'S': letter[y] = 'F'; break;

case 't': case 'T': letter[y] = 'G'; break;

case 'u': case 'U': letter[y] = 'H'; break;

case 'v': case 'V': letter[y] = 'I'; break;

case 'w': case 'W': letter[y] = 'J'; break;

case 'x': case 'X': letter[y] = 'K'; break;

case 'y': case 'Y': letter[y] = 'L'; break;

case 'z': case 'Z': letter[y] = 'M'; break;

default: break; } y++; z++; } } return letter; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Information Modeling And Relational Databases

Authors: Terry Halpin, Tony Morgan

2nd Edition

0123735688, 978-0123735683

Students also viewed these Databases questions

Question

=6/What is a standard financial analysis plan?

Answered: 1 week ago

Question

What are some global employee and labor relations problems?

Answered: 1 week ago

Question

Where those not participating, encouraged to participate?

Answered: 1 week ago

Question

Were all members comfortable brainstorming in front of each other?

Answered: 1 week ago

Question

4. What will the team agreement contain?

Answered: 1 week ago