|
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., 3:50pm),
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 Figure.java
before the time deadline.
Here is the command to submit your work:
-
%
submit 1020 midtermR2.30 Figure.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 Figure.java.
It should prompt for, and then read in, at the console one positive integer:
the number of rows in the figure to be drawn.
Do input validation to check that the input number of rows
is positive.
Throw an exception using type.lib.ToolBox otherwise
with the message, "Number of rows must be positive.".
If the entered number of rows is even, the application should print out
a square with that number of rows and columns. The '*' symbol should be
used to print the square. (Note: since row and column spacing are
different, the output may look more like a rectangle than a square; what
is important is that the number of '*' characters printed in each row
is the same as the total number of rows.) All rows should start in the
first output column; i.e., do not "indent" your figure.
If the input number of rows is odd, print a triangle with the input
number of rows. Again, use the '*' symbol to print this figure.
The triangle should be "balanced" as shown in the sample output.
The first row should have 1 '*', the second row 3 '*'s, and so on.
Do not print any blanks after the last '*' on each row; just end the line.
The last row must start in the first output column. Again, see the
sample output.
|
|
Sample Runs
Here
are 2 sample runs of a correctly written program.
User input is shown in red.
% java Figure
Enter a positive integer ... 4
****
****
****
****
%
% java Figure
Enter a positive integer ... 5
*
***
*****
*******
*********
%
|
|
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.
|
|
|
|