Given a string, return a new string where the last 3 chars are now in upper case. If the string has less than 3 chars, uppercase whatever is there. Note that str.toUpperCase() returns the uppercase version of a string.
endUp(”Hello”) ? “HeLLO”
endUp(”hi there”) ? “hi thERE”
endUp(”hi”) ? “HI”
public String endUp(String str) {
if(str.length() < 3) return(str.toUpperCase());
else return str.substring(0,str.length()-3)+str.substring(str.length()-3).toUpperCase();
}


#1 by Cam Chat at July 26th, 2010
Hey, great blog…I’ll add your site in my rss reader, if I can figure out how to get it to work…LOL