Write a method that converts its String parameter so that letters are written in
blocks five letters long. For example, consider the following two versions of the
same sentence:Plain: This is how we would ordinarily write a sentence.
Blocked : Thisi showw ewoul dordi naril ywrit easen tence
p.s....the code still have the error in JCreator(JAVA).....dont know how to solve it.....pls help me to solve this problem.....
public class String {
public static void main(String [] args) {
String convertToFive;
int string = new string;
string = s;
{
StringBuffer result = new StringBuffer();
for (int k = 0; k < s.length(); k++) {
if ((k+1) % 5 != 0){
result.append(s.charAt(k));
}
else if ((k + 1) % 5 == 0)
result.append(s.charAt(k) + " ");
}
return result.toString();
} // convertToFive()
String s = "This is how we would ordinarily write a sentence.";
String stripS = s.replaceAll(" ", "");
}//end main
}//end class