COSC-071: Computer Science I

Homework 2
Spring 2011

Written part due in lecture, Thu, Feb 3
Program submission due: Feb 3 @ 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 1.1 (page 21) and 2.1 (page 35).

    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.1, 2.2, 2.3, 2.4, 2.5 at the end of Chapter 2 and submit these written exercises in lecture.

  3. To learn how we'll be submitting projects this semester, you'll be submitting Program 1.1 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/cosc071/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
    seva$ cp ~maloofm/mm.cshrc ./.cshrc      <--- Copies settings for your account
    seva$ source .cshrc                      <--- Applies those settings
    seva%
    

    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., prog11.cc). So, to submit prog11.cc for this assignment, you type:
    seva% java -jar submit.jar -a hw2 -f prog11.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 net ID, the spelling of which is critical. You should not need to provide this information again.

    You must submit your program before 5:00 PM on the due date. The written part of the assignment is due in lecture.