|
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).
|
|
Instructions
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., 6: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 Carpet.java
before the time deadline.
Here is the command to submit your work:
-
%
submit 1020 labtest1W5.00 Carpet.java
Note that in labtest1 above, the '1' is the character
one, not the letter 'L'.
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.
Even if you are unable to finish all aspects of the program,
you should still check it in.
|
|
Useful APIs
Here
are the common APIs that you may access:
|
|
Template Java Program
-
/* Name
* CSE Account #
*/
import java.io.PrintStream;
import java.util.Scanner;
public class Template
{
public static void main(String[] args)
{
PrintStream output = System.out;
Scanner input = new Scanner(System.in);
}
}
|
|
|
|
Write a Java application
called Carpet.java that calculates the cost of
carpeting a floor.
It should prompt for, and then read in, at the console
two numbers:
- a real number, the diameter measured in meters of a circular room
- a real number, the price per square meter of carpet
The application should print out the cost of purchasing just enough
carpet to cover the floor of the room (ignore the fact that
the carpet is probably rectangular and the room is round).
Note that the carpet
store sells carpet in whole number of square meters, so you
need to round the area of the floor up up to the
nearest integer value. Also, you may assume that the
price entered by the user is a monetary amount (that is,
it has at most 2 digits to the right of the decimal).
Recall that the area of a circle is
π * ((1 / 2) * d)2 where
d is the diameter of the circle.
|
|
Sample Runs
Here
are two sample runs of a correctly written program.
-
% java Carpet
-
Enter the diameter of the room : 2
-
Enter the price per square meter : 5.25
-
Total cost is 21 dollars and 0 cents
-
% java Carpet
-
Enter the diameter of the room : 3.1
-
Enter the price per square meter : 8.99
-
Total cost is 71 dollars and 92 cents
-
%
|
|
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 should comment at least minimally,
as by the guidelines.
You should not use any features of Java not covered
in the first three chapters of the text;
in particular, do not use if-statements or loops.
There will be some deduction if you do.
|
|
|
|