Saint Louis University |
Computer Science 144
|
Dept. of Math & Computer Science |
Topic: Strings
Related Reading:
pp. 234-240 of Ch. 7 of text,
Processing tutorial on Strings/Text
Due:
11:00am, Thursday, April 9, 2015
Note that homework assignments should be submitted in class as hard copy (although you are welcome to test your solutions with Processing).
For this assignment, you must work individually.
Please make sure you adhere to the policies on academic integrity in this regard.
Preface: With understanding of the relevant documentation, you should be able to predict the results for these questions, but you may also choose to try some of these out in Processing to determine the outcome.
Assume that the following variable has been initialized:
String school = "Saint Louis University";Predict the return value of each of the following commands:
There is an important difference between the functions split and splitTokens, which we illustrate with the following two examples:
Assume that the variable birthday is a string that describes a date such as "3/31/15" or "12/9/1906". You cannot assume the number of digits in any part, but you can presume there are precisely two slashes and that if a two digit number is given for the year, that it implictly begins with 20 (i.e., the "15" means "2015").
Give a code fragment that assumes such a general
birthday string and defines three integer
variables, month, date, and year with
the appropriate values. That is, if the birthday string were
"3/31/15" then you should end up with