Lab must be completed and
reviewed by Peer Instructor on Tuesday, Sept 2 during lab class and no later
than the first 10 minutes of lab class on Thurs, Sept 4.
Description
In this lab you'll create
a new Java program that will generate the output specified below.
Task 1 - Prepare to create
your own 1st Java program.
- You may want to look
at the Java programs from Lab 2 to remind you of the structure required. In
fact, you can even copy a program, rename it, and use it to write this program.
Task 2 - Create the class
and method headers
- The class name should
be lab3 (so it will have to be saved in a file named what?)
- Since there will be only
one method, what should the name be?
- Make sure there's a comment
above the method describing what it does.
Task 3 - Build the comment
(banner) at the top of the program.
- Remember to include your
name, the section and course number, the assignment (lab3), and a description
of what the program will do.
- Use the // or /* symbols
to denote your comment.
Task 4 - Create some
variable declarations.
In your program, declare
7 variables:
- three int
variables (larry, moe &
curly) - initial values should
be set to 2, 4, & 6,
- one char
variable (letter) - initial
value should be set to 'X',
- one boolean
variable (test) - initial value
should be set to true
- two double
variables (abbott & costello)
- initial values should be set to
1.5 & 2.63
Task 5 - Create the print
and assignment statements necessary to complete the lab.
- First, print some header
lines. They should look like this: (use tabs in front of your name)
Lab 3 Your
name
---- ---------
- Use the println method
from the System.out object to output a string concatenated with the value
of each of the 7 variables.
Example: System.out.println("larry's
value is " + larry);
would produce the output:
larry's value is 2
- Output a blank line.
- Output the sum of larry,
moe and curly on a line, along with a descriptive label.
- Output another blank
line.
- Output the sum of abbott
and costello on a line, along with a descriptive label.
- Output another blank
line.
- Output the concatenation
of all 7 of the variable's values on one line. No spaces necessary.
Example (these are not the correct values): 3423false21.02.0
Task 6 - Compile and
execute the program.
Completion Requirements
Once you've completed the
lab, you should show the Peer Instructor that you have completed:
-- Run the lab3 program,
-- the PI will compare the specified output to your output.
-- then use PFE to show the lab3.java file to the PI, your comments and code
structure will be checked.