ITEC 120 LAB 2 Back to Lab index page

Lab must be completed and reviewed by Peer Instructor on Thursday, Aug 28 during lab class and no later than the first 10 minutes of lab class on Tues, Sept 2.

Description

In this lab you'll copy two Java programs from this page to your folder. You'll compile and run the first one as is. You'll have to correct errors in the second one before it will compile and run. Once you've run the second program, you'll make changes to it and save it as a new source program, compile and run it.

Task 1 - Copying files from this web page to your ITEC120 directory.

example1.java example2.java

Copy these two files to your ITEC120 directory on your network drive. (It should be automatically mapped.) If you are using Explorer, when you click on the two links above, it will ask you if you want to save these, click yes, save to your ITEC120 folder on your virtual drive (H:).

Task 2 - Compile and run your first Java program.

-- Open firstexample.java in the PFE by double clicking on it.
-- Look at the code, notice how the comments are indicated. Look at the class and method definitions.
-- To compile the program, once the file has been opened in PFE, select Execute, then Compile
-- This should give you back a window without error messages, if it compiled correctly - which it should.
-- You must close this window before you can continue working with original source file, firstexample.java.
-- Now select the Execute, then Run
-- You should see the output from the program, again in its own DOS window
-- Make sure you look back at a listing of the files in your ITEC120 directory (on your H: drive), what file was created?
-- Close this window and the firstexample.java file that is open in PFE

Task 3 - Compile, debug and run the second Java program.

-- In PFE, open example2.java
-- Follow the same procedure to compile it.
-- There is an error in this source file. What message does the compiler output?
-- Look at the source code carefully (example2.java) -- what's wrong with it?
-- Correct the error using PFE, recompile and run it.

Task 4 - Modify the second program and save as a new file, then recompile and run.

-- Change the second program, give it a new class name.
-- Change print to println statements
--
Add 3 more println statements to output more text - output a blank line, your name, and a row of dashes ----
-- Save it to a file that has exactly the same name as the new class name you chose, remember to include the .java extension.
-- Compile and Run the program.

Completion Requirements

Once you've completed the lab, you should show the Peer Instructor that you have completed:
-- Run the example2 program,
-- Run the new program, with changes you implemented.
-- Show both source files to the Peer Instructor.