Several of the exercises below involve string manipulation. Here are some helpful String methods:
someString.length()
returns the number of characters in a string.
someString.substring(0, 1)
returns the the first letter of someString
.
someString.substring(1)
returns everything after the first letter. This will return the empty string ("") if the string only has one letter.
Other methods involve processing integers one digit at a time. Here we can use the /
and %
operators:
int num = 745; int last = num % 10; // evalutes to 5, the last digit of 745. int rest = num / 10; // evaluates to 74, all of the digits except the last.
You are not required to work on these in order, but they do build on each other to some extent. If the exercises from Group 1 seem too easy, feel free to skip ahead to Group 2. To receive credit for the lab you must finish at least four exercises beyond "bunnyEars".
Don't use the "next" button to move between exercises: after you have completed an exercise come back to this page and select the next one.