Skip to main content.

Assign 0: Getting Started

Objectives:

Due: Before the next class (Wednesday).

Setting Up Your Account

Create a directory for cs209 in your home directory and a subdirectory for assign0 within the cs209 directory.

It is important that you name your directory and files as I specify because I use some automated scripts to ease the grading process.

Part 0: Practice on a Given Program

Part 1: Your First Program

In your favorite text editor, create a Java class called Intro in a file named Intro.java. The Intro class's main method should print out, on separate lines, your name, your favorite color, and your favorite pop culture character. For example:

Sara Sprenkle
Favorite Color: Purple
Favorite Pop Culture Character: Tina Belcher

All the top-down design principles from CS111 and CS112 apply in every computer science course. Do not try to write the entire program in one attempt. Break the problem into manageable pieces.

You should write only a little code at a time, then compile and execute it (see directions below) so that you find bugs quickly. You're just getting used to the new Java syntax, so I'm sure you'll run into problems. If you run into problems, compare your code to the examples from class.

Make sure your program is well-documented, as discussed in class.

Compiling the Program

In a terminal, from the directory that contains Intro.java, compile your program using javac Intro.java

If there are errors, fix those errors and re-compile until it works.

Executing the Program

In a terminal, from the directory that contains Intro.java, execute your program using the command
java Intro

If the output is not what you expect, edit your program, recompile and execute.

When you're sure your program is working correctly, execute your program using the command
java Intro > output, which writes the output from java Intro into the file output.

If you are spending more than about 30 minutes on this program, something is wrong. Talk to me.

Part 2: Fixing A Program

Objective: The goal of this part of the assignment is to get you familiar with the required Java syntax, the compiler's error messages, and how to fix the errors so that the program compiles. Debugging is one of the most important skills you learn from programming, so it's good to practice, especially on a small program.

Save Assign0.java into your assign0 directory.

This program contains at least 5 errors. Some are compiler errors that the compiler will catch. Others are logic errors that the compiler won't catch.

Comment out the original code and note the cause of the error. Then, correct the code.

Since you are inexperienced with Java, what are good ways to figure out the errors? You should have several different approaches to solving these problems (and that doesn't involve Web searches).

Saving the Final Output

After you're sure the program works correctly, save the output in a file called debugged.out as you did in the last problem.

Turning in Your Assignment

Copy your assign0 directory into your turnin directory, using the turnin.sh script.

For example: /csdept/local/courses/cs209/shared/turnin.sh assign0

There will be a slightly easier way to submit soon.

The turnin.sh script assumes the locations of your files, primarily that you created the directory cs209 in your home directory and that you named your directory appropriately.

The script is copying your files into /csdept/local/courses/cs209/turnin/yourusername

To verify that your code has been copied, you will need to use the command-line, e.g., using ls /csdept/local/courses/cs209/turnin/YourUserName/

There is no printed part of this assignment.

Grading (80 pts)

You will be evaluated based on

Part 1 (20 pts)

Part 2 (40 pts)

Style/Indentation (10 pts)

Turnin (10 pts)