Lab must be completed and
reviewed by Peer Instructor no later than Thurs, Jan 16 during lab class, and
no later than Thurs, Jan 23, during the first 10 minutes of lab. (Tuesday, Jan
21 is a lab quiz. No labs will be checked on that day).
Description
In this lab you'll extend
your lab3 Java program and submit it TO NEELIX. Remember, you must complete
lab3 and have it checked before you start on lab 4. You don't want to modify
lab3 before it's checked by the Peer Instructor.
Task 1 - Changing your
lab3 program
- First, you'll want to
open your lab3.java file using PFE
- Change the class name
to: userid_lab4 (userid refers to your logon id at RU, not your password)
(an example of a new class name might be: johndoe_lab4)
- Under the FILE menu in
PFE, select FILE, SAVE AS, enter the new filename, i.e., johndoe_lab4.java
(important -- remember the first part of the file name and the class name
must be exactly the same)
- You should now have the
new file open in PFE (so, you're ready to make the changes listed in the following
instructions.)
Task 2 - Changing your
lab3 program, add a casting section
The following should be
added to your program, now named userid_lab4:
- at the bottom (but before
the closing brace) for method main, add:
- a comment that says this
is the casting section
- declare a new variable
of type byte (named smallint)
and initialize it to 0
- using a println, print
a blank line
- using println, print
the string "Value of smallint:" and the value of smallint
- assign 132 to smallint
(you'll have to cast the number 132 to make this work.)
- using a println, print
a blank line
- using println, print
the string "Value of smallint:" and the value of smallint
- use an assignment statement
to assign the value of 202.0 to
num
- assign the value of num
to smallint (again, you'll
have to cast num to make this work)
- using a println, print
a blank line
- using println, print
the string "Value of smallint:" and the value of smallint
(compile and run. is this the correct value for smallint?)
- using assignment statements
set the value of :
- int1
to 6
- int2
to 79000000 (79 million. 79 with 6 zeros)
- make num
be assigned the value of the product of int1
& int2
- using a println, print
a blank line
- using println, print
the string "New Value for num :" and the value of num
(is this the correct
value?)
- make int1
be assigned the value of num * 1000
(you'll have to use casting on num to make this work, why?)
- use println to output
a string like "New Value for int1 is: " and the value of int1,
(is this the correct value?)
Task 3 - Submit the program
TO NEELIX.
You must complete this
part on Thursday, Jan 16!
- Click on Start, Run,
type in: \\neelix\dropbox , and click OK
- Double click on ITEC,
ITEC120, asbrennem or cshing, Submissions, ITEC110-yoursection-Spring.
- You should see a folder
with your username on it.
- Copy your program, uname_lab4.java,
into your folder.
Task 4 - Add a string
method section.
As with the section above,
add a comment at the bottom of your source code that says this is the string
section
- declare a variable message
of type String and initialize its value to "All I wanna do is code JAVA."
- declare another character
variable (type char) named foundletter,
give it no initial value
- use the charAt String
method to find the character in the 6th position of message
and assign it to foundletter
- use a println to output
a descriptive string and the value of foundletter
- use the length String
method to assign the length of message
to int1 (what parameter is
required?)
- use a println to output
a descriptive string and the value of int1
Completion Requirements
Once you've completed the
lab, you should show the Peer Instructor:
- Run the lab4 program,
- the PI will compare the
specified output to your output.
- then use PFE to show
the userid_lab4.java file to the PI, your comments and code structure will
be checked.
- PI's will also check
to see your file is in the class lab4 folder on neelix (task 3)