Program 0

Computing Infrastructure

Introduction to Computer Science I
ICS-21


Introduction This first "programming" assignment is not a "programming" assignment at all; it is designed to ensure that you know the fundamentals of using the computing infrastructure for this course, both on your own machine (if you have one) and the computers in our labs. Primarily it concerns starting to learn to use the Eclipse Integrated Development Environment (IDE) for Java, which is available on both the Microsoft Windows and Mac Operating System. Knowing how to use these tools is a first important first step towards being able to learn how to program well.

Subsequent programming assignments will have much less of a cookbook flavor; instead, they will focus on designing, writing, and debugging programs in Java from the specifications that I supply. But, these assignments will assume that you are already an experienced Windows/Mac OS and Eclipse user, who knows all the tools and skills covered in this assignment, and can easily apply them when writing his/her own actual programs.

So, treat this assignment very seriously: you will not want to still be learning this material at the same time that you are writing your early programs. Now is the time to begin mastering these important tools and skills.

Finally, read and follow these instructions carefully. It would be an excellent idea to print a copy of this web page, read through it, and highlight any details that you think are important (and might forget as you are working on the assignment) or that you are confused about. Some students lose points for failing to follow directions properly; this is a problem that gets worse during the quarter, so starting out by doing the "right thing" in this assignment is an excellent idea. If you have any questions about these instructions, for example, if you think they are in error, or just confusing, please contact me. Do it directly by sending email to me, or for issues of concern to everyone in the class, by sending email to the class discussion list; often you can do both in the same email, making it trivial for me to reply directly to you while answering your discussion email (going to the rest of the class) at the same time.

Carefully read the last two sections, on Extra Credit and Time Management. These important sections are relevant to all programming assignments, but appear only in this one.


Part 1:
Questionnaire
Download a copy of the course Questionnaire, which is a Microsoft Word file. Read and edit this questionnaire (in Microsoft Word), filling in the answers to all its questions. Note that the questions on the first page are about you, your experience, your goals, and your expectations; the questions on the second page require you to practice navigating the course web site, to find useful information about this course. After you have filled-in this questionnaire, submit it using the Homework Dropff link on the course web page.

Part 2:
Using the Eclipse IDE
Read through Windows Operating System & Eclipse IDE web page (which is also accessible on the Handouts web page). It includes all the information that you initially need to know about using the Eclipse IDE. This includes
  • Downloading programming projects from the web (and unzipping them)
  • Starting Eclipse
  • Creating Projects: new ones from scratch and previously existing ones
  • Editing Java files
  • Compiling programs, correcting syntax errors, and running programs
  • Uploading/downloading projects from ICS Lab accounts (and/or USB memory)
  • Submitting programming assignmnments through Checkmate homework dropoff system
When you have finished reading and following the instructions in this document, perform the tasks shown below, culminating in successfully dropping off two very simple working Java programs. If you have any questions, feel free to ask for help from me, any staff member, or other students at UCI. Please cross the "question answering threshold" quickly; get into the habit of being able to ask us questions, especially in lab.

To do this assignment, you must have already downloaded and installed Java and the Eclipse IDE on your own computer (or be using one of the UCI Lab machines, where it has already been downloaded/installed).

In the first part, you will start a new project and write a trivial program.

  • In Eclipse, create a new Java project and a new class in it (in the anonymous package), both named Test1. When creating that class, specify (via a checkbox) inclusion of a public static void main(String[] args) method (otherwise you will have to type in this code yourself).
  • First, delete the comment (lines 4-6) and instead put a comment on line 1 with your name. My comment would appear as
    //Richard Pattis
  • Replace the body of that method, by replacing the line
    // TODO Auto-generated method stub
    comment by the single statement
    System.out.println("Java program test scceeded!");
  • Run (compile and execute) this program to ensure that it produces the correct output in the Console. You might need to edit it if you incorrectly typed the line above; in fact, if you know a bit of Java, now is a great time to experiment with introducing, recompiling, and fixing small syntax errors -by seeing how the Eclipsed IDE reports and helps correct them.
  • Close this project; in fact, go ahead and delete this project from the the workbench, but ensure the Delete project contents on disk (cannot be undone) button is NOT checked.
  • Move the project folder from the workspace onto your desktop.
  • Copy this project folder (including its contents) onto your ICS Lab space and/or USB memory (always do this to save your work, even if you are using your own computer; you can optionally zip it first).
  • Delete this project folder, empty the recycle bin, and log off your computer.
  • Log back on to the computer; download the project folder that you just uploaded onto the desktop put it in some folder (not the workspace), to ensure that you saved it correctly (unzip it first, if necessary). You should be able to create a Java project and specify this project file as the existing source from which to create the project. Ensure that it still compiles and executes correctly.

If you have any problems, please ask for help during the lab. After you are finished, repeat these steps a few times, until you can do them from memory. This programming assignment is very cookbook, but by the end you should have mastered the steps needed in creating and manipulating projects with Eclipse -something you will do over and over again during the quarter.

After you have finished, submit the file you created, Test1.java, using the Homework Dropff link.

In the second part, you will download a project and use it in the Eclipse IDE.

  • Download the Collatz project folder and unzip it to a folder on your desktop. It should contain only one file, named Collatz.java.
  • In Eclipse, create a new Java project named Collatz, click the Create project from existing source radio button, and then browse to specify the Collatz folder as the existing source from which to create the project.
  • Edit the Collatz.java file. Diclose and read the comments at the top of the Collatz.java file to understand what this program does.
  • Try to run the program as an application. Eclipse will indicate four syntax errors; ensure that you see the error messages in the Problems tab, on the bottom window: disclose these four errors. Note: If an error involves the Prompt.forInt method, it means that you did not correctly follow the instructions at the end of the Installing Java and Eclipse document for installing the class library; redo those steps.
  • Fix these three errors as follows (you are not expected to understand these errors yet). Be careful! The descriptions of the errors aren't great: two specify a way to fix a problem, but NOT THE RIGHT WAY for this code. We cannot just blindly follow these suggestions.
    1. In the expression statement on line 67 (do you have the line numbers turned on in Eclipse? if not turn them on), put a + after the last String in quotes, and before the identifier testNumber.
    2. In the expression statement on line 75, put a ; (semicolon) after the ++ operator.
    3. In the expression statement on line 76, replace the = operator by the == operator (no spaces between the two equal signs).
    4. In the expression statement on line 77, replace the identifier testnumber by the identifier testNumber (notice the capital N).
  • After fixing the errors, save the program and try to run the program again. When prompted for a number, enter 7, which ultimately requires 17 cycles to be reduced to 1.
  • Close this project; in fact, go ahead and delete this project from the the workbench, but ensure the Do not delete contents button is checked.
  • The Collatz.java file in the Collatz project folder you used to create this project should be updated with the fixes that you entered.
  • Copy this project folder (including its contents) onto your ICS Lab space and/or USB memory (always do this to save your work, even if you are using your own computer; you can optionally zip it first).
  • Delete this project folder, empty the recycle bin, and log off your computer.
  • Log back on to the computer; download the project folder that you just uploaded onto the desktop put it in some folder (not the workspace), to ensure that you saved it correctly (unzip it first, if necessary). You should be able to create a Java project and specify this project file as the existing source from which to create the project. Ensure that it still compiles and executes correctly.
If you have any problems, please ask for help during the lab. After you are finished, repeat these steps a few times, until you can do them from memory. This programming assignment is very cookbook, but by the end you should have mastered the steps needed in creating and manipulating projects with Eclipse -something you will do over and over again during the quarter.

After you have finished, submit the corrected file you modified Collatz.java, using the Homework Dropff link.

Bottom Line

You will be writing many programming assignments during the quarter, requiring you to create new projects or modify existing ones. You should be able to manipulate both kinds of projects easily in Eclipse.

Also, whenever you want to write a small program to test out your understanding of Java, you should have a very low threshold to quickly creating a project and writing the experimental code that you want to test.


Extra Credit Programming assignments must be turned in on time: you can get partial credit for a partially completed assignment, but it must be turned in on time; I will accept no late homework unless you have an official excuse pre-arranged with me (and even then you should turn in whatever work you have completed by the due date/time). In fact, there is another incentive to finish not only on time, but to finish early.

In all programming assignments, if you turn in everything at least 24 hours before it is officialy due, you will receive 1 point of extra credit. If you turn it in 48 hours (or earlier), you will receive 2 points of extra credit. (There is no more extra credit for early turn-ins; I recommend NOT turning it in more than 48 hours early.) This is equivalent to a half a grade improvement (e.g., C+ to B, or B to B+, or B+ to A) on a 40 point assignment. In previous quarter, over 50% of the students completed their assignments early and received some amount of extra credit; it adds up.

There are two main advantages to planning on finishing early. First, if you run into a major problem, you will have extra time to solve it before the actual due date: and even experienced programmers frequently run into such problems. Yes, this means you! Second, and more importantly, if you are racing to finish before a deadline, stress levels can go through the roof, and you become less interested in learning the material (and the whole purpose of these programming assignments is to learn the material) and more interested in just getting it finished. If you do not learn the material, you will be at a major disadvantage for all subsequent programming assignments and tests, because of the cumulative nature of the material in this course. Therefore, plan to finish every assignment by Monday or Tuesday evening.

Programming assignments sometimes also include an extra credit section worth 1-2 points. These are designed for students who finish early and want to continue exploring programming within the context of the assignment. The points are to acknowledge, in a small way, their extra effort.

This assignment has no special extra-credit section. You can get extra credit on it only for an early dropoff.


Time Management One of the hardest parts of being in college is learning how to manage your time. Time management is especially important in programming courses (and in the real world, when you are working on complicated projects with hard deadlines). The difference between good and bad time management can have a profound impact on how much you learn in this course, how well you perform in it, and how much effort you actually need to expend to do well.

I will try to divide most programming assignments into a series of smaller tasks, each that can serve as a milestone; when solved in sequence, these tasks will complete the entire assignment. When we start writing programs, we will discuss such a divide and conquer method more formally, calling it iterative enhancement.

Generally, it is best to spread out the work on a week-long assignment. Most assignemnts become available on Thursday morning; I recommend reading the assignment during lab (the day it is discussed in lab) so that if you are unsure about any parts of it, you can ask relevant questions about them in lab; this reading includes running the executable files included with each assignment, to see how the program should behave (including its input and output -which you must match). You should start working on it during lab, and should plan to complete at least half the programming assignment over the weekend. You should finish it early the following the week: if not by Monday, you can use the lab on Tuesday to get finish it, asking questions of the starff during the lab.

Some students look at an assignment and think that it is best done in one sitting. If you can do so, great; but, if you plan to work this way, do the one sitting over the weekend, not Wednesday night! In this way, if you are wrong about the amount of time that it will take, you will still have adequate time to complete the assignment. By meeting these time goals, you will both maximize what you learn and minimize your anxiety and the time that it takes for you to do the learning.

Remember that assignments must be turned in on time: you can get partial credit for a partially completed assignment, but it must be turned in on time; I will accept no late homework unless you have an official excuse pre-arranged with me (and even then you should turn in whatever work you have completed by the due date/time).

Finally, if you find yourself falling behind, seek help immediately (from me, the TA, the Lab Tutor, or even other students in the course -when appropriate). When the real programs start, we will discuss what kind of help you can get legitimately, and what kind of help constitutes cheating.