CS 101 (Fall 2002)
Lab 1: Expressions, Functions, and Procedural Abstraction
Authors: Jonathan D. Wetherbee
| || 9 ||Sep
|| 10-11 ||Sep
|| 17-18 ||Sep
|| 20 ||Sep
By the end of this lab, you should...
be able to write Java expressions for mathematical formulas.
understand procedural abstraction, formal parameters, actual parameters,
and return values.
be able to define procedures that describe simple computations.
understand naming abstraction, and the difference between a name and a
- Read over the entire lab.
- Browse the documentation , particularly
the description of MyGruntWork .
- Before beginning the assignment, download the provided portions of the
lab into your cs101 folder by clicking on the "download project" button in
the on-line version of this assignment.
- Run the sample solution.
- You will probably want to read the
- Check out resources for
project folder for PC]]]
You're a programmer for Texas Instruments and the new high-tech CS101 Calculator
is about to be released. Your job in this lab is to code the mathematical
and boolean functions into the calculator.
You will write a
MyGruntWork class that implements GruntWork.
- Begin by opening the MyGruntWork.java file in Emacs. (When you choose "Open
File..." from the Files menu, a message will appear at the bottom of the screen
asking which file you wish to open. Please see a TA if you need assistance.)
Supply the necessary header information (name, lab section, etc.). This
is the only file you are allowed to modify for this lab. Look over the file carefully before modifying it! Please note the following:
- There is a place for each of your methods in the file. All you need to do
is fill in the code where it says "Delete this line and replace it with the correct code".
We declare each of
the methods properly for you; you do not need to worry about method declarations,
just their bodies.
- Sometimes there are partial implementations that tell you important hints
about how to accomplish some of the requirements. Please delete any code
which does not end up being a part of your solution, especially if we have
marked it for deletion! The code is there to illustrate how to do things
in Java; it is not meant to serve as part of your solution unless it is explicitly
stated as such.
The JavaDoc (documentation) for this lab details the input parameters and return
values that each method should compute.
Hint: To avoid making the same mistakes over and over, test very frequently as you go.
That is, type in the body of a procedure, compile, execute, and verify the results, and
then go on to the next problem. After you get the hang of it, you can
write more code before you test. Detailed instructions for running your
program are listed below.
Execute your program by opening Lab1.java
(in the same folder as
MyGruntWork.java) and compiling it (choose
"Compile" under the "JDE" menu). After the compile has finished successfully
(you will see a message saying so), you may run the program by choosing "Run
App" from the "JDE" menu.
You should see a calculator interface. Fully test each method to ensure the
high-tech CS101 Calculator is ready to be released.
Run the SAMPLE SOLUTION!!
What To Turn In:
For every CS101 lab you turn in, you should fill in
sheet and staple it on the front of your lab.
Attach a paper printout of the following:
This must be turned in by
the start of class
on the due date. Check that you have
header information (name, email, date, and lab section) at the top of the
file, and you must have demonstrated your lab to have the printout graded.
MyGruntWork.java file containing the methods you wrote
If you need
help printing, ask a TA or refer to the help homepage, which has detailed
instructions for how to print from the labs.
Last modified 08:25:32 CDT 12 September 2002
by Ron K. Cytron