I am trying to convert String into ascii, alter the ascii value, and then convert those values back into a string. I though I was on the right track, but I am getting an error message telling me I must return a String; where did I go wrong?
public static boolean safeToUse(String text) {
text = text.toUpperCase();
int length = text.length();
for ( int a=0; a < length; a++ ) {
char c = text.charAt(a);
if (c < FIRST || c > LAST) { //checking range
return false;
}
}
return true;
}
public static String rot31(String message)
{
message = message.toUpperCase();
int length = message.length();
for ( int x=0; x < length; x++ ) {
int ch = message.charAt(x);
if (ch <= 62) {
int ascii = ch + 31;
} else {
int ascii = ch - 62;
String coded = Integer.toString(ascii);
return coded;
}
}
}