York University
Department of Computer Science and Engineering

CSE 1020: Introduction to Computer Science I

Fall 2007

Labtest 1
1:00 p.m. Tuesday, October 9, 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 value of a simple expression involving fractions. To store the fraction values, you must use the type.lib.Fraction class.

Your program should be called Expression.java. As shown in the sample runs below, it should prompt for and then read in integer values a b c d e and f (in that order) and then calculate and output the value of the following expression:

    a     c     e
    -  *  -  -  -
    b     d     f
Again: you must use the type.lib.Fraction class.

Sample Runs

Below are two sample runs of a correctly written Expression.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., 1 3 5 3 2 9) is also shown here.


%
% java Expression
Enter values for the 3 numerator denominator pairs: 1 3 5 3 2 9
The value of the expression as a fraction is 1:3.
The expression as a double output to 2 decimal places is 0.33.
%
% java Expression
Enter values for the 3 numerator denominator pairs: 13 53 43 2 65 11
The value of the expression as a fraction is -741:1166.
The expression as a double output to 2 decimal places is -0.64.
%


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 labtest1T1 Expression.java