public class LoopFun { /** * Given a number, return the factorial of that number. * For example, given 5, the factorial is 5 x 4 x 3 x 2 x 1 which should return 120. * @param number * @return the factorial of the number */ public int factorial(int number){ int total = 0; for (int i=1;i<=number;i++) { total = total * i; i++; } return total; } /** * Given a phrase, get the acronym of that phrase. Acronym is the combination of * the first character of each word in upper case. * For example, given "Ruby on Rails", this method will return "ROR" * @param phrase * @return Upper case string of the first letter of each word */ public String acronym(String phrase) { StringBuilder newStr = new StringBuilder(); String[] array = phrase.split(" "); for (int i=0;i 'd' * 'w' => 'z' * 'x' => 'a' * 'y' => 'b' * @param word * @return the encrypted string by shifting each character by three character */ public String encrypt(String word) { String encrypted = ""; for (int i = 0; i < word.length(); i++) { if (((char)(word.charAt(i) + 3) > 'Z' && word.charAt(i) <= 'Z') || ((char)(word.charAt(i) + 3) > 'z' && word.charAt(i) <= 'z')){ encrypted = encrypted + (char)(word.charAt(i) + 3 - 26); } else {encrypted = encrypted + (char)(word.charAt(i) + 3); } encrypted = encrypted + word.charAt(i); } return encrypted; } }