York University
Department of Computer Science and Engineering

CSE 1020: Introduction to Computer Science I

Fall 2007

Labtest 1
5:00 p.m. Wednesday, October 3, 2007


Welcome To The Labtest Environment!

During the test, you will not be able to access your regular home directory, access electronic mail, send or receive email, 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 prior to the end of the test (instructions to submit your code are provided below).  If you do not submit your work on time, you will receive a grade of zero (there will be no exceptions).

Important:  When you submit a file, you must include, at the top of the file, your name (first, last) and your Prism lab login.
These should be placed in a comment, so the file will compile. Files that do not compile will receive a large penalty when marked, no matter how small the error that prevented compiling.


The Task

Your task for this test is to write a simple app which calculates and outputs the surface area of a frustrum, as described below.

A frustrum is what remains if you take a cone and slice off the top parallel to the base. Below is a picture of a frustrum, along with formulas for calculating the surface area and volume.

Your app should be called Frustrum.java. After appropriate prompts, the user will input values for the lower radius, the upper radius and the height. (No units like centimetres, etc. are required here.) These numbers must be positive and the lower radius must be larger than the upper radius. Your app will then calculate and output the surface area (along with some headers and the 2 radii and height) as shown in the sample runs below.

Sample Runs

Below are two sample runs of a correctly written Frustrum.java program. Your output (including prompts) should be identical to that shown here. (Of course the '%' signs are shell prompts and not part of the output.)
Note that sample user input (e.g., 100 and 85.1234 and 25.1) is also shown here.
The output numbers should be displayed with exactly 2 digits after the decimal point.


%
% java Frustrum
Enter frustrum lower radius ... 100
Enter frustrum upper radius ... 85.1234
Enter frustrum height ... 25.1

Lower Radius Upper Radius       Height         Area
============ ============ ============ ============
      100.00        85.12        25.10    16,969.09

%
% java Frustrum
Enter frustrum lower radius ... 9999.12345
Enter frustrum upper radius ... 1000
Enter frustrum height ... 50.9999

Lower Radius Upper Radius       Height         Area
============ ============ ============ ============
    9,999.12     1,000.00        51.00 310,967,593.45

%

If you cannot format the output as shown above, try (for a small penalty) to format it as shown below (using the same input as the second example).


%
% java Frustrum
Enter frustrum lower radius ... 9999.12345
Enter frustrum upper radius ... 1000
Enter frustrum height ... 50.9999

Lower Radius = 9,999.12
Upper Radius = 1,000.00
Height = 51.00
Area = 310,967,593.45
%

Coding

You should use good programming practices as described in the text. Your code should conform to the style guide in the text. If you cannot set the size of tabs in your editor, then use spaces instead of tabs. Do not use any features of java not covered in the first four chapters of the text.

Time Limit

You have about 90 minutes to complete this test (i.e. till the end of the regular lab period). No additional time will be provided and the machines will be switched out of lab test mode automatically. 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.

Useful APIs

Here are the common APIs that you may access:

Java 1.5 API
Type API

Submitting Your Work

Submit the class Frustrum.java before the time deadline.
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 labtest1W5 Frustrum.java