CSCI 121 Lab Assignment 1
|
Outcomes: Upon completion of the lab, the student will know
how to |
||
|
|
· Log
onto the Engineering Computer Lab |
|
|
|
· Navigate
around the network |
|
|
|
· Save
files to the J: drive |
|
|
|
· Use
the DrJava IDE to |
|
|
|
· Interactively
evaluate Java expressions |
|
|
|
· Edit,
compile, and execute simple Java applications |
|
|
Activities: |
||
|
1 |
Login to the lab network using the username and
password assigned to you by the Computer Lab staff. · Your
username is in the form FMLLLL, where F is your first initial, M is your
middle initial, and LLLL are the first 4 letters of your last name · Your
password is the last 6 digits of your student number. You should change your password when you
login for the first time. |
|
|
2 |
Following the instructions given by the lab
instructor, locate your J: drive and examine its contents. · The
J: drive is storage that has been allocated to your computer lab
account. · You
will save all your work on this drive (not C:). |
|
|
3 |
Locate and double-click the DrJava icon on the
desktop. It looks like this: |
|
|
4 |
In the Interactions pane at the bottom of the
screen, enter the following expressions and record the result of each on the
lab sheet provided: |
|
|
|
A |
3 + 5 % 4 |
|
|
B |
3 / 6 |
|
|
C |
(double)3 / 6 |
|
|
D |
(3 + 5) % 4 |
|
|
E |
5.1 / 2 |
|
|
F |
Math.sqrt(5) |
|
|
G |
“A Java String”.indexOf(“ava”) |
|
|
H |
String name = “bob”; name.toUpperCase() |
|
|
I |
name |
|
|
J |
String str; str |
|
|
K |
str.toUpperCase() |
|
|
L |
str = “ Roberts” |
|
|
M |
str.toLowerCase() |
|
|
N |
name + str |
|
|
O |
name.toUpperCase() + str |
|
|
P |
(name + str).toUpperCase() |
|
|
|
|
|
5 |
Enter the following text in the Definitions pane
of DrJava (this code contains an error, but type it as written anyway): public class LabAssignment1 |
|
|
6 |
Click the Save button on the DrJava
toolbar. · In
the drop down box labeled Save In:, navigate to the J: drive. · Make
sure “Java source files” is selected in the Files of Type
textbox, then click “Save”. · This
will save your file under the name LabAssignment1.java on your J drive. |
|
|
7 |
Select the Tools menu item, then select Compile
Current Document. Write the error
message that is displayed on the lab sheet provided. |
|
|
8 |
Fix the error in the code for LabAssignment1. Then repeat steps 6 (Save) and 7 (Compile
Current Document). This time you
should see the message “Last Compilation Completed Successfully” |
|
|
9 |
Select the Tools menu item, then select “Run
Document’s Main Method”. Show the
result to the lab instructor and have the instructor sign the lab sheet in
the space provided. |
|
|
10 |
Log off the network and turn in the lab sheet to
your instructor. |
|