CSE 113 - Spring 2008 - Banner
   CSE 113 - Spring 2008 - Introduction to Computer Programming I
CSE 113 - Spring 2008 - Navigation

Module 1

Introduction

In this first lab assignment you will:

  • set up your account so that you can work with DrJava for the rest of the semester
  • learn some basic Unix commands that you will need throughout the semester
  • start DrJava and use the interactions pane to write some Java expressions and statements
  • save your interactions history from DrJava
  • submit your work using the electronic submission program


Run Setup Script

You need to run a setup script in order to more easily work on the labs this semester. After you log in, type:

~alphonce/cse113init

at the prompt. This will set up your account so that all you need to do is type drjava at the prompt and the DrJava program will open up for you.


Unix Commands

  • ls - This command gives a listing of the files in a directory. Without any arguments, it provides a listing of the files in the current directory, and is therefore equivalent to

    ls .

    If you specify a directory using a path, ls will respond with a listing of the contents of the specified directory. Try typing ls at the Unix prompt to see if you have any files in your directory. If this is a brand new account, you may not have any, but if you do, they were put there to help make your account function properly. Never delete any files that you did not create.

  • cd - This command changes the current directory. Without any arguments, it changes the current directory to your home directory, and is therefore equivalent to

    cd ~

    If you specify a directory using a path, cd will set the current directory to the specified directory. One neat thing is that using .. as an argument to cd moves you to the parent directory.

  • Using wildcards - Wildcard characters are used in patterns to match filenames. For example, the wildcard character ? matches any single character. Another wildcard that will be useful is the * this character, which matches multiple characters.

  • man - The man command brings up a manual page (help screen) for a specified command. Let's get the man page for the finger command by typing man finger.

  • mkdir - This command creates the specified subdirectory. Create a directory called temp by typing

  • mdkir temp

  • cp - This command copies a file to a new location, leaving the original unchanged.

  • mv - This command moves a file from one location to another. But beware, because of the way file systems work, moving a file is very similar to renaming. The mv command is also the rename command. A directory is just a special type of file to Unix, so we can rename the directory we just created before by moving it to a new location. For example we can rename the directory called temp by:

    mv temp cse113

  • rm - The command rm removes a file. It is adviseable to always use the rm command with the -i flag so that you are prompted to decide if you really want to remove something.

  • rmdir - This command removes the specified subdirectory.

Lastly, you should know how to open the web browser so that you can refer to information on the course website while you work on this and future labs.

For now, you should make sure you have a directory named cse113. Inside the cse113 directory, you should create directories for modules 1 through 10 so that you don't have to do this for each assignment. This way, you can save your work from each module into its own place.


DrJava Exercises

You should open DrJava and activate the Interactions pane by clicking the tab that says interactions. We saw in class that the interactions pane allows us to type expressions into the prompt and DrJava will evaluate those expressions. Many of these exercises are inspired by what is covered in Chapter 2 of the text. Feel free to refer to the text as you are working on these exercises.

  1. Type in at least one arithmetic expression that uses simply the +, -, *, or / and whole (integer) numbers.
  2. Type an expression that divides two integers that you know creates a whole number as an answer (6/3 for example).
  3. Type an expression that divides two integers that you know is not a whole number answer (6/4 for example).
  4. Type the same expression as above, but substitute the decimal number equivalents (6.0/4.0 for example) and note the difference in the answers you receive.
  5. Type all of the same expressions above, but this time put each in a System.out.println() statement . The results should be the same as you saw previously.
  6. Type a statement that prints the string that contains your name to the screen. For example, I would type System.out.println("Adrienne Decker");
  7. Type a statement that mixes Strings and the value of an expression. For example,
    System.out.println("Adrienne's favorite number is: " + (6 + 12 - 6 * 1));
  8. Use the interactions pane to solve question 2.8 on page 35 of the text. Calculate how long it would take to travel 770 miles at an average speed of 60 miles per hour. What is the amount if you travel 70 miles per hour?
  9. Create a variable called name that holds the String which represents your name. Make sure to assign your name to that variable.
  10. Print out the value stored in the above variable using System.out.println();
  11. Declare a variable for the number of people in your family. Assign the appropriate value to that variable.

Save Your Interactions History

When you have completed all the exercises, you will need to save the interactions history to show that you have completed this lab. This means that you will need to do all the exercises at one time in order to have them all saved on the same interactions history. Alternatively, you will need to save what you have done temporarily and the next time you start DrJava, load up your history as a script and use the "Execute" Button that will appear on the right of the navigation pane to execute all of the instructions you have saved in your script and continue from where you left off.

To save the interactions history, place your mouse in the Interactions pane and then right click. Choose the option that says "Save Interactions History..." You can select "No" when asked if you want to edit before proceeding. Then, save the file in your module 1 directory that you created. You should name the file Module1.


Submission

You will now have a file called Module1.hist. Submit this file by going back out to the Unix prompt and typing:

submit_cse113 Module1.hist


Due date

Your lab submission is due no later than 11:59:59 pm on February 8th. Remember, no late labs will be accepted.


Lab authored by Adrienne Decker

CSE 113 - Spring 2008 - Footer

 

 
Page Maintained by: Adrienne Decker