Program 1

Computing Infrastructure

Introductory/Intermediate/Advanced Programming/Practicum
15-100/15-111/15-200


Introduction This first "programming" assignment is designed to ensure that you know the fundamentals of using the computing infrastructure for this course, whether it be your own machine or the computers in our clusters. Primarily it concerns the use of both the Microsoft Windows Operating System (or the Mac OS) and the Eclipse Integrated Development Environment (IDE) for Java (available on both operating systems). Knowing how to use these tools is an important first step in learning how to program well.

Subsequent programming assignments will have much less of a cookbook flavor; instead, they will focus on writing 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 their 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 semester, 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, please contact me (either directly by email, or for problems of concern to everyone in the class, by posting to the bboard; often you can do both in the same email, making it trivial for me to reply directly to you while answering your bboard post 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, zip it first and then drop it off to the Program #1 (Questionnaire) instrument (off the Homework Dropff link).

Be careful to select the correct assignment when you drop off your program. This is the #1 mistake students make: some students accidentally drop it off in the wrong folder (practice or Program #1 (Eclipse)) and lose points. Always archive all the mail that you receive from the drop off system (which acknowledges each dropoff), and save it for the entire semester, in case discrepancies arise about when you dropped off assignments. This very rarely happens, but problems are much easier to resolve if you have kept all e-mail sent by the dropoff mechanism.


Part 2:
Windows/Mac OS and Eclipse IDE
Read through Windows / Mac 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 Windows/Mac OS and the Eclipse IDE. This includes
  • Downloading programming projects from the web (and unzipping them)
  • Starting Eclipse
  • Creating Projects: all new code/built on old code
  • Editing Java files
  • Compiling programs, correcting syntax errors, and running programs
  • Saving/uploading projects to Andrew accounts
  • Retrieving/downloading projects from Andrew accounts
  • Zipping files
  • Submitting programming assignmnments through the homework dropoff system
When you have finished reading the appropriate document, perform the tasks shown below, culminating in successfully dropping off two very simple working Java programs (each project in a separate folder; both folder in a single enclosing folder named appropriately). If you have any questions, feel free to ask for help from me, any staff member, or other students at CMU (e.g., those in your dorm): every year a thousand students learn exactly these same procedures in their introductory programming courses. Fall 2005 Caveat: Unfortunately, because Eclipse is new this semester, you may have difficulty finding experts on campus.

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 CMU cluster machines, where it has already been downloaded/installed). Follow the instructions on the Computing Infrastructure handout/web page.

  • Part A
    • Create a new Java project in your workspace and a new class in it (in the anonymous package), both named Test1. When creating that class, specify (via a checkbox) inclusion of a main method (otherwise you will have to type this code yourself).
    • Make the body of that method the single statement
      System.out.println("Java program test scceeded!");
    • Run (compile and execute) this program to ensure that it produces the correct output. 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 making and fixing small syntax errors -by seeing how the system reports and helps correct them.
    • Close this project; in fact, go ahead and delete this project from the the workspace, but ensure the Do not delete contents button is checked.
    • Move the project folder from the workspace to your desktop.
    • Upload this project folder and all its contents onto your Andrew account (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, to ensure that you saved it correctly (unzip it if necessary). You should be able to create a Java project and specify this program as the existing source from which to create the project. Ensure that it compiles and executes correctly.
  • Part B
    • Download the Collatz project folder and unzip it. It should contain only one file, which defines the Application class.
    • Create a Java project in your workspace named Collatz and browse to specify Collatz as the existing source from which to create the project.
    • Edit the Application class. Read the comments at the top of the Application class to understand what this program does.
    • Try to run the program as an application Eclipse will indicate three syntax errors; there will be multiple indicators for each error; ensure that you see the error messages in the Problems tab, on the bottom window. 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; redo those steps.
    • Fix these three errors. 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.
    • After fixing the errors, try to run the program again. Another error becomes manifest.
    • Fix the remaining error.
    • Run the program. 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 workspace, but ensure the Do not delete contents button is checked.
    • The Collatz project folder you used to create this project should be updated with the fixes you entered.
    • Upload this project folder and all its contents onto your Andrew account (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, to ensure that you saved it correctly (unzip it if necessary). You should be able to create a Java project and specify this program as the existing source from which to create the project. Ensure that it still compiles and executes correctly.
  • Part C
    (see the Extra Credit section first; for extra credit, you will include a third project folder with the other two when you zip and drop off the result).
    • Put the Test1 and Collatz project folders into a new folder named like pattis-1 (but your last name, followed by the assignment number). Zip thie folder and drop it off to the Program #1 (Eclipse) instrument (off the Homework Dropff link).

    Be careful to select the correct assignment when you drop off your program. This is the #1 mistake students make: some students accidentally drop it off in the wrong folder (practice or Program #1 (Questionnaire)) and lose points. Please archive all the mail that you receive from the drop off system (which acknowledges each dropoff), and save it for the entire semester, in case discrepancies arise about when you dropped off assignments.


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. 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 over half a grade improvement (e.g., C+ to B, or B to B+, or B+ to A) on a 30 point assignment. In previous semesters, almost 75% of the students completed their assignments early and received some amount of extra credit

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.

For one point of extra credit on Program #1, create a new project folder named ExtraCredit that contains a class/program that prompts the user for an upper bound and then computes and prints which number (from 1 to that upper bound, inclusive) has the longest cycle length -and print the cycle length for this number. If more than one number has this longest cycle length, print the smallest number. If any numbers cause an overflow during the computationi, ignore them. But in this case, print an extra message at the end indicating how many numbers were ignored -because any of these might have a larger cycle length. This version does not print anything else; just the few lines of input and output described above.

I suggest that you modify a copy of the orignal Collatz code to solve this related problem.


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 Wednesday; I recommend reading the assignment before Friday (the day it is discussed in class) so that if you are unsure about any parts of it, you can ask relevant questions about them in class; 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 plan to complete at least half the programming assignment over the weekend, and then plan to finish the rest early in the week (by Monday or Tuesday, to get any extra credit).

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 not accept any late homework unless you have an official excuse.

Finally, if you find yourself falling behind, seek help immediately (from me, the CAs, 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.