Normally I recommend that you work in pairs, but today I'd like each of you to work by yourself so that you get set up and used to the DrJava programming environment. After today if you do work in pairs you should each fill out your own lab sheet to get checked off. Also, you should always take turns driving.
In this course we will be using some Java code that allows us to interact with media, such as images, sound. What you'll do in this step is to make your own personal copy of these files and you'll change a setting in DrJava to indicate where these extra files can be found. It's not terribly exciting, but important to get right.
CS140
.
T:\Harcourt\Fall2008\CS140\downloads\cs140Classesto the CS140 folder you just created.
cs140Classes
folder you just
copied there.
cs140Classes
directory to select it as the path you want to add. If you accidentally
double clicked on the directory, click on the "Up One Level" button
(looks like a folder with an arrow pointing up).
/* * This is my first CS140 Java program. This is a comment * that briefly describes what the program does. * * Author: Ed Harcourt * Date: 8/21/08 * */ public class Lab1 { // This is the start of the main method. Every Java // program must have this. public static void main(String [] args) { // this is where body of the main method starts StdOut.println("Hello world!"); } // end main method } // end class Lab1
Lab1.java
.
Compilation completed.
in the Compiler Output
tab
at the bottom.
Run
button in the upper part of DrJava.Console
tab in the lower window and see what happened.
You should see Hello World!
.
Next, we'll add to our first java program.
Lab1
program.
Question 1: What does the following statement do?
StdOut.println("Val:" + 1 + 2 + (3 + 4));
What steps does the computer do to create the result?
Question 2: What is the difference
between the statements StdOut.println(1/2);
and
StdOut.println(1.0/2.0);
? Why
do they evaluate to different values? What are the values?
Question 3: Modify the program to calculate and print how much money you will make if you work 40 hours at $13.00/hr and an additional 10 hours at time and a half wage. Let the program do all the calculations. Don't do any of the math in your head or use a calculator. Save the code on your screen for your instructor check-off.
When you are satisfied that you have successfully followed the instructions above, and answered the questions, raise your hand and either the TA or instructor will check you off.