The Question

Write a java program called Q2.java that will do the following: Read in a series of tokens of the of the form String:double, where the string is a person's name and the double represents points achieved in one session of playing a game. Examples might be
David:35.123   Fred:128.1
	Alexander:231
Fred:45.34
Note that the same name may appear more than once. The program should read all such tokens and then output, with appropriate headings, a list of the players and, for each, the total points (to 2 decimal places) he/she has achieved. The list should be sorted in non-decreasing order by player name. There is a restriction on player names: a legal name must be at least 4 characters long and may not contain a ':'.

If a token is read that does not conform to these specifications, it should simply be ignored by the program.

HINT: Store the (name, points) pairs in a map.

The output should conform to that in the sample runs of a correct program shown below. Note that, in these sample runs, the % sign is not part of the output. User input is shown on the same line as the prompt.

Sample Runs

% java Q2
Enter the scores:
William:20.12
Dave:10.25
William:10.111
blah
Dave:hello
Dave:1.100

      NAME     POINTS
      ====     ======
      Dave      11.35
   William      30.23
% 
% java Q2
Enter the scores:
Dave:25.10001    Michael:10.341
blah blah blah
Michael:three
   Fred:100.5  Dave:20.2
Kay:100.25
blah blah Dave:10.3
Fred:10.0
Dave100

      NAME     POINTS
      ====     ======
      Dave      55.60
      Fred     110.50
   Michael      10.34
% 

Useful APIs

Here (again) are the common APIs that you may access:

Java 1.5 API
Type API

Submitting Your Work

Here is the command to submit your work (further details regarding the submit command can also be obtained by typing man submit
Once again, you are encouraged to submit regularly. Newer submissions overwrite older ones.

submit 1020 exam Q2.java