1. Write a method that will compute for the length of a non-negative number.
METHOD SIGNATURE
EXAMPLES INPUT OUTPUT
pig igpay
computer omputercay
chair airchay
apple appleay
public static int length(int input)
input a non-negative integer. returns the length of the input.
EXAMPLES INPUT OUTPUT
5. Write a method to decide if two strings are anagrams or not.
METHOD SIGNATURE
0 1
110 3
3210 4
public static boolean isAnagram( String a, String b)
returns true if anagram, false otherwise.
EXAMPLES INPUT OUTPUT
RULES
Arrays and Strings are not allowed. 2. Write a method that will sort a non-negative integer.
METHOD SIGNATURE
pig, gip
true
banana, potato
false
public static int sorted(int input)
6. Write a method to replace all spaces in a string with %20.
METHOD SIGNATURE
input - a non-negative integer. returns the sorted input.
EXAMPLES INPUT OUTPUT
public static String replace(String input)
EXAMPLES
0 0
110 11
321 123
INPUT OUTPUT
hello world hello%20world
RULES
Arrays and Strings are not allowed. 3. Write a method that reverses a string.
METHOD SIGNATURE
7. Given an integer between 0 and 999,999, return an English phrase that describes the integer.
METHOD SIGNATURE
public static String inWords(int input)
public static String stringRev(String input)
EXAMPLES INPUT OUTPUT RULES
EXAMPLES INPUT
100
"One Hundred"
1,234
"One Thousand, Two Hundred and Thirty Four"
a a
abc
cba
abc123 321cba
OUTPUT
Built-in method reverse() is forbidden to use. 4. Write a method that will convert a word to piglatin. A piglatin is formed by moving the first group of consonant to the end of a word and appeding ay.
METHOD SIGNATURE
public static String piglatin(String input)