Computer Science 121
Assignment 6
Due: March 26, 2003

For this assignment you are to write a program using a StringTokenizer to read the data.  The data should consist of the name of a city followed by a list of doubles that represent the amount of rainfall on different days during the preceding month.  All the data should be entered on a single line, separated by spaces.  Some city names, such as New York, consist of several words.  Use a plus sign (+) instead of a space when reading in the names.  Since it usually doesn’t rain more than a few days out of the month, all the data should fit on a line.

Use the Body Mass Index and the Store Tokenizer examples to see how to use a StringTokenizer.  Read the data in one method and display it in another.  In the read method, add each number to a running sum in order to compute the total amount of rainfall for the month.

When done, display the data on the screen.  Format your output using the method, decimals, from the Reader class.   You can just copy that method into your program as is done in the body mass index example.  You can also change the plus sign in the city’s name to a space using the replace method in the String class.  Use
    cityName = cityName.replace ('+', ' ');
to do so.  The replace method will replace all instances of the first parameter by the second one.  The formal definition from the Java documentation is:

replace
public String replace (char oldChar, char newChar)
Returns a new string resulting from replacing all occurrences of oldChar in this string with newChar.

If the character oldChar does not occur in the character sequence represented by this String object, then a reference to this String object is returned. Otherwise, a new String object is created that represents a character sequence identical to the character sequence represented by this String object, except that every occurrence of oldChar is replaced by an occurrence of newChar.

Parameters:
    oldChar - the old character.
    newChar - the new character.
Returns:
    a string derived from this string by replacing every occurrence of oldChar with newChar.