COSC 071: Computer Science I

Homework 2
Spring 2007

Written part due in lecture, Thu, Feb 1
Program submission due: Feb 2 @ 5 PM
5 points

This homework is designed to get you familiar with entering, compiling, and submitting C++ programs.

  1. Using g++ on seva, enter, compile, and run the C++ programs Program 2.1 (page 51), 2.2 (page 53), 2.6 (page 57), 2.8 (page 68), 2.9 (page 75), and Program 2.11 (page 94).

    As you know from lecture, g++ is available on seva, the department's student machine. Here are some pages that will help you complete these tasks:

    You'll be submitting all projects this semester with a submit program, which you'll need to copy from my directory to your directory. Instructions follow.

    A simple editor on seva is "nano", which is a full-screen editor. nano has on-line help, and there is also documentation on the nano home page. For nano, once inside the editor, you can type Control-G to get help.

    If you plan to take additional CS courses or to develop further your programming skills, then I'd highly recommend learning either "vi" or "emacs". nano is simple, but it is also simplistic, especially for editing C++ code. vi and emacs are industrial-strength tools for writing programs.

  2. Do exercises 2.4, 2.5, 2.6, 2.7, 2.8, 2.9, 2.12, 2.19, 2.20 on pages 98–100 in Cohoon and Davidson and submit these written exercises in lecture.

    Note: For problem 2.8, remove both include statements.

  3. To learn how we'll be submitting projects this semester, you'll be submitting Program 2.11 from the book, which you entered previously. Once this program has been submitted successfully, you'll be sent a receipt by e-mail.

    You first need to get a copy of the program you'll be using to submit your projects. On seva, you need to copy the submit program from my directory to yours. At the prompt, which I'll assume is seva$, type the following commands, hitting the enter key after each line. (What you type is set in boldface. Everything else is a comment or something the computer prints.)

    seva$ cd ~                        <--- Changes the directory (cd) to your top-level directory (~)
    seva$ cp ~maloofm/submit.jar ./   <--- Copies (cp) the submit program (submit.jar)
                                           from my top-level directory (~maloofm) to
                                           your current directory (./)
    seva$ ls                          <--- Lists the files in the directory
    submit.jar                        <--- You should see submit.jar in the list
    

    submit.jar is a Java program that will take a file and send it to the machine we use for grading. To submit a file for an assignment, you type at the seva prompt:

    seva$ java -jar submit.jar -a <assignment> -f <file>
    
    where <assignment> is the name of the assignment (e.g., hw2) and <file> is the name of the file to be submitted (e.g., prog211.cc). So, to submit prog211.cc for this assignment, you type:
    seva$ java -jar submit.jar -a hw2 -f prog211.cc
    
    N.B. The submit program currently doesn't like file names with hyphens and underscores, so please avoid them.

    The first time you use the submit program, it will ask you for your name, the spelling of which isn't important, and your net ID, the spelling of which is critical. You should not need to provide this information again.

    The TAs who will be grading your projects this semester are listed on the main page. You must e-mail your project before 5:00 PM on the due date for the e-mail portion of the assignment.