CS 101 - Intro to Computing, Spring 2008

Lab 6

For this week, we want to switch over to the CS Department's computer lab in SEL 2254 (enter through SEL 2250 or SEL 2260). These computers run the Linux operating system, so you will need to learn some basic UNIX/Linux commands. These commands are used into in a "terminal window".

The userID and password for the CS Department's machines are not the same as your NetID and password. The userId is normally the first letter of your first name and upto seven letters of your last name. If you are not a CS major, you may end up with a "temp" account. The temp accounts have the userId begin with the 4 letters "temp" and end with some number. To find out your exact userID, there are lists posted in the CS Lab stating everyone's userID and name. The default password for the CS account is your UIN.

The Basic UNIX Commands

The UNIX commands that you will need for this lab are:

Other UNIX Commands

There a literally hundreds of UNIX commands and I doubt that anyone knows all of them. A few other UNIX commands that you may want to know are: For more information on UNIX commands check out the ACCC's web page UNIX 101. It gives a nice summary on various UNIX commands.

Running DrJava in the CS Labs

To run DrJava in the CS Labs, you will first need to copy the bookClasses directory and set the classpath. There is a script (i.e. small operating system program) that will do this for you. From a terminal window, enter the following:
     ~i101/setupDrJava
Only enter the above command once.

After the bookClasses directory has been set up, enter the following command to start DrJava:

     ~i101/runDrJava
Once DrJava is up and running, it should work the same as it has on the ACCC's windows machine. Actually is should work better. At least, it will run faster.

Lab Assignment

Due: Thursday 10/9/2008 by 11:59 pm

For this lab assignment, complete the following:

  1. Modify the program from class on Sept. 25th that increased the brightness of an image. The program is Lect925a.java. You are to prompt the user for a number and brighten the color at each pixel the number of times entered by the user. Thus you are to add another loop to the code so that you have one loop nested inside the other loop. One loop will loop through all of the pixels in the image. The other loop will loop the number of times specified by the user's input.

    To get the user's input, we will use the getIntNumber() method of the SimpleInput class. The SimpleInput class is one of the classes in the bookCAlasses directory. This method will display a "pop-up" window that will prompt the user to enter an integer value.

    The getIntNumber() has two ways it can be used. In either way, it takes a String parameter will be displayed as a message when the user is prompted for the input. That is the only parameter for the first way that getIntNumber() can be used. The other way also takes two more parameter which specify the range the number enter by the user must be in. The following code shows both of these ways.

    // declare in integer variable to store the number entered by the user.
    int value;
    
    // prompt the user for the number
    value = SimpleInput.getIntNumber ("Please enter an integer value.");
    
    // display the value entered by the user
    System.out.println ("The user entered: " + value);
    
    // prompt the user for a number within a range of values
    value = SimpleInput.getIntNumber ("Please enter an integer value between 1 and 10.", 1, 10);
    
    // display the value entered by the user
    System.out.println ("The user entered: " + value);
    

    For this lab, you can use either form of the getIntNumber() method that you want. If probably makes sense to use second version of the method. The lower number in the range should be one. Values less than one don't really make any sense. (Perhaps the value of zero could make sense, if you wanted to run the program that didn't do any modifications to the image. But then why run the program at all?) The upper number in the range could be somewhere around 10, because running brighten() on a color too many times will result in a pure white (or nearly pure white) image.

    Your program must prompt the user for the image file to use (as was done in the code in Lect925a.java), prompt the user for the number of times to brighten the image, brighten the image as specified by the user, prompt the user for another filename in which the resulting image could be stored (as was done in the code in Lect925a.java).

  2. Be sure to include a comment at the top of your program containing the following information:

  3. You are also to submit the Java file electronically by using the Linux/UNIX turnin command onthe CS Machines. You are to submit the code using the project name of lab6. If your file was named lab6.java, you would type in the following command to submit your program using turnin:
         turnin -c cs101 -p lab6 lab6.java
    
    To verify what you submitted using the turnin command, type:
         turnin -c cs101 -p lab6 -v
    

  4. You are also to submit a hardcopy of your java source code file. You can