|
Welcome to the Labtest Environment
|
|
During
the test,
you will not be able to access your regular home directory,
access, receive, or send e-mail, print, or access the Internet.
|
|
Points.java
You have about 80 minutes
to complete this test. Before the end of the 80 minutes, you must
submit your program and log off the machine. Do not leave your
machine without logging off, or the next person to use it will have
access to your code and could overwrite it. The lab monitors will
announce when the 80 minutes are nearly up. Anyone not logged off
after 80 minutes will lose marks.
You are encouraged to submit often during the test.
Newer submissions overwrite older ones.
|
|
Submitting Your Work
When
you submit a file,
you must include at the top of the file your name (surname, given name)
and your Prism lab login.
These should be placed in a comment so that the file will compile.
Note that files which do not compile will receive a large penalty
when marked,
no matter how small the error that prevented compiling.
Submit the class Points.java
before the time deadline.
Here is the command to submit your work:
-
%
submit 1020 ... Points.java
(Further details regarding the submit command can also be
obtained by typing man submit.)
Once again, you are encouraged to submit regularly.
Newer submissions simply overwrite older ones.
Unlike eCheck assignments,
there is partial credit possible.
If you are able to finish all aspects of the program
(for example, say, input validation was requested
but you did not do this),
you should still check it in.
|
|
Useful APIs
Here
are the common APIs that you may access:
|
|
|
|
Write a Java application
called Points.java.
It should read in (unprompted) from standard input a series of
string/integer pairs. These tokens will be separated by whitespace.
The string part represents the name of a player who has played a game
and the integer represents that player's score for one attempt at the
game. A player may play multiple times. In that case, the player's
name and score will appear multiple times. Player names are case-sensitive
and no two players have the same name. You may assume that the input
contains no partial records, i.e. no name without a corresponding score and
no score without a corresponding name.
Your application should print out a list of players and for each player
the total score achieved, as shown in the sample run below. The list
of players should be sorted in reverse alphabetical order (see the example
below). If there is no input or the input is just whitespace, then your
program should produce no output.
A Map is a good way to store the data read by your program.
Note that, in each input player-score pair, the score is expected to be
an integer. If it is not, for example, if the score entered contains
a fractional part like 35.5 or is a string like xxxx, then that
player-score pair should just be ignored, as if it had never been entered.
(If your code does not accomplish this - ignoring bad player-score pairs -
you could still receive up to 80% of the possible marks.)
|
|
Sample Run
Assume you have a file called "Players" with the following contents:
Dave 25
Mike 100
Dave 80
Dave 5
Gordon 99.99
Bill 10
Zbibniew 50
Mike 50
Dave xxxx
Here
is a run of a correctly written program with the input redirected
to come from the "Players" file.
% java Points < Players
Zbibniew:50
Mike:150
Dave:110
Bill:10
%
Note that there is no blank or other whitespace after the output score,
except for a newline character.
|
|
Coding
You
should use good programming practices
as described in the textbook,
and your code should conform to the style guide in the textbook.
You code must be properly commented. You should use appropriate
classes and methods and favour simplicity over convoluted approaches
that "somehow" manage to come up with the right answer.
|
|
|
|