|
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.
At the end of your test session,
this machine will be converted back to a standard, unrestricted
Prism Lab machine.
At this time, any files written by you during the test,
except those that have been submitted,
will not be recoverable.
Make sure you submit your code
before the end of the test .
(Instructions to submit your code are below).
If you do not submit your work on time,
you will receive a grade of zero.
(There are no exceptions).
|
|
Time Limit
You have about 80 minutes
to complete this test (regular lab time).
The computers will automatically shutdown at the end of the lab
(e.g., 8:20pm),
warning you several minutes in advance.
No additional time will be provided,
so you must submit your work prior to this;
otherwise, there will be no way to recover it (it will be lost),
and you will receive a grade of zero (no exceptions).
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 DivideUp.java
before the time deadline.
Here is the command to submit your work:
-
%
submit 1020 midtermR7.00 DivideUp.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 DivideUp.java.
It should prompt for, and read in, a fraction cutoff
as a pair of inputs for the numerator and denominator.
It should then prompt for, and read in, a list of fractions,
each as a pair of a numerator and a denominator.
These fractions should be stored and manipulated by the program
using the type.lib.Fraction class.
The input and output here are standard I/O;
i.e., unless redirected,
input comes from the keyboard and output goes to the screen.
To signal end of file or no more input
on a Unix system, just type <ctrl>d
(the control key and letter d at the same time)
at the start of a line.
(In the sample output below, the <ctrl>d typed by the
user is not shown.)
After reading all the input,
the program should output
how many of the fractions in the list were
larger than (or equal to)
the cutoff fraction.
If there were some,
it should also report the sum of these
as a "proper fraction"; e.g., "1 3/5", instead of "8/5".
Print the proper fraction of the sum quoted.
The program then should output
how many of the fractions in the list were smaller than
the cutoff fraction.
Again, if there were some,
it should also report the sum of these as a proper fraction.
Your output format should conform to that shown below
in the sample output.
The input will be of the form
numerator denominator numerator denominator ...
for the cutoff fraction.
The input will be of the form
numerator denominator numerator denominator ...
for the list of fractions.
You can assume (i.e., do not have to check)
that the input never includes
a numerator entry without a following denominator,
that all the entries are non-negative integers,
and the denominators are all positive.
You should use the Fraction class
and the appropriate methods in it.
You will lose marks for implementing functionality yourself
if an appropriate Fraction method could have been used
easily instead.
For instance,
you should use Fraction to compare two fractions
(e.g., to see which is larger),
and not do this yourself in your code
(for full credit).
Also remember good programming style.
Style is graded too.
|
|
Sample Runs
Here
are two sample runs of a correctly written program.
Anything typed by the user is shown in red.
% java DivideUp
Enter the cutoff: 1 2
Enter a list of fractions: 1 3 1 4 1 5
The number of fractions larger than (or equal to) the cutoff was 0.
The number of fractions smaller than the cutoff was 3.
They summed to "47/60".
%
% java DivideUp
Enter the cutoff: 2 3
Enter a list of fractions: 7 8 5 11 4 9 3 8 5 6 1 7
The number of fractions larger than (or equal to) the cutoff was 2.
They summed to "1 17/24".
The number of fractions smaller than the cutoff was 4.
They summed to "1 2311/5544".
%
|
|
Coding
You
should use good programming practices
as described in the textbook,
and your code should conform to the style guide in the textbook.
Your code should be adequately commented.
|
|
|
|