COS 126

Assignment 0: Hello, World
Programming Assignment


The purpose of this assignment is to introduce you to programming in Java and familiarize you with the mechanics of preparing and submitting assignment solutions. You will learn to use the DrJava editor for writing, compiling, and executing programs.

Installing the course software.  The introcs package includes everything that you need for this course: the Java compiler and runtime, the DrJava development environment, the course libraries, and tools checkstyle-introcs and findbugs-introcs that you can use to review your work.
The installer is a new version for Fall 2013. If it seems to be broken or unusable, check with lab TAs and report issues on Piazza where we can determine what advice to give everyone.

Programming.  Your job is to write two more short programs on your own. We'll assume that you have already created, compiled, and executed HelloWorld.java by following the instructions in the previous part of the assignment.

  1. Command-line arguments. Read Section 1.1 of the textbook. Modify UseArgument.java to make a program HiFour.java that takes four names as command-line arguments and prints out a proper sentence with the names in the reverse of the order given, so that, for example,
    % java HiFour Alice Bob Carol Dave
    
    outputs
    Hi Dave, Carol, Bob, and Alice. 
    

  2. Integer variables. Read Section 1.2 (through page 22) of the textbook. Write a program SumThree.java that reads in three integer command-line arguments. The program then outputs all three numbers and their sum in the form of an equation.
    % java SumThree 2 5 8
    2 + 5 + 8 = 15
    

Program style and format.  Now that your program is working, go back and look at the program itself. Did you include a header that will tell the reader who wrote the program, and what it does? (If you are planning on doing any professional programming, you should get into the habit of also including instructions for compiling and running the program.) For full marks, your program should not only work correctly, but should conform to the recommended style and format so that it is easy to follow. Read Booksite Appendix B: Writing Clear Code. Follow the guidelines in the Reviewing your Programs section of the checklist.

Writeup.  With each assignment you must submit a text file named readme.txt that is a narrative description of your work. Some weeks there are also analysis questions to complete. We provide a readme.txt that you should use as a template. Download this file and answer all questions in the space provided.

As indicated in the readme template, part of this week's assignment is to complete the Collaboration Quiz. You will need to read the COS 126 Collaboration Policy in order to complete it.

Questionnaire.  Part of this assignment is to fill out the following brief questionnaire.

Browsing the course website.  The next part of the assignment is to browse the COS 126 website. The address is:

http://www.princeton.edu/~cos126
It is essential that you understand what's where and how to get to it. Please follow the Treasure Hunt worksheet on the Precepts page. (You may complete this part with a classmate.)

Submitting the assignment.  The final part of the assignment is to submit HelloWorld.java, HiFour.java, SumThree.java, and readme.txt via the Web submission system called Dropbox. To do this, click the Assignments link from the course website; click the Submit link for that assignment; and (if you aren't already logged in) login using your OIT NetID and email password. Upload the required files, and click the Check All Submitted Files button. Your programs should compile without errors or warnings; if not, fix the problem and resubmit the appropriate files. Remember that every file you submit needs to have your name, netID, and precept number.

Getting help. If anything is unclear, don't hesitate to drop by office hours, post a question on Piazza or email us. We also recommend reading the checklist, which provides some clarifications and answers to frequently asked questions.