Lab01, CISC181, Spring 2004

Welcome

Lab one has three parts.

Part One: Web Page

This part involves several commands to get both a "personal" web page up on strauss (if you already have one, you are already finished with that step), as well as a CISC181 specfic web page.

Note that your personal web page (the one that comes up when you type in http://copland.udel.edu/~userid) can be anything you want. I will not require anything regarding that page, except that it has to exist. If you want it to be devoid of content, that is up to you.

However, you are required to have a web page that comes up at the following link:

http://copland.udel.edu/~userid/cisc181
where userid is... well... your userid. To make that happen:
  1. Create the subdirectory "public_html" under your main directory, and then the subdirectory "cisc181" under that. If you are not sure how, read up in your Anderson text (A6 and A8 may be particularly helpful). Hint: You will need the "mkdir" and "cd" commands. I also went over this in lecture.
  2. Make your home directory "world executable". (A series of commands to do it: cd; chmod a+x .). (The "chmod" command is covered in Anderson chapter 6 as well.)
    (Note: your home directory is the the one that has your user number on it; for example, pconrad's home directory is /home/usra/d9/55560. You can find anyone's home directory with the command finger userid)
  3. Go into the cisc181 subdirectory, and create a file called index.html. (You'll use vi or emacs to create this file).

    When you ask for a directory, but don't ask for any particular file, index.html is always what gets displayed first. (Sometimes, index.htm will do the trick as well, but index.html is a nicer name.)

    What should that file have in it? Some HTML code for your personal CISC181 page (an example appears below.)

    Again, for your "personal" CISC181 page, you may have any content you want, as long as it contains at least one link. The link is the part that has the <a href=...> tag around it (we talked this morning in lecture about what a "tag" is.)

    Here's some example HTML to get you started.
    
    <html>
      <head>
        <title>Joe Sample's Web page</title>
      </head>
    
      <body>
        <h1>Joe Sample's Web page</h1>
    
        I had to do this <b>web page</b> for my 
       <a href="http://udel.edu/~pconrad/cisc181"> CISC181 class</a>.  Right now it is
        pretty lame, but I hope to make it better later.
    
    
      </body>
    </html>
    

    Here's what that looks like once it is formatted by a web browser:

    Joe Sample's web page

    I had to do this web page for my CISC181 class. Right now it is pretty lame, but I hope to make it better later.

  4. To see that it works, type into a web browser:
    http://copland.udel.edu/~userid/cisc181

    If it doesn't come up, make sure you set all your file permissions correctly. The most common problem is not doing the "chmod a+rx index.html" on the file to make it world readable. If you did that, and it still doesn't work, check with your TA or with a classmate for help.

  5. Now go back and put an index.html file into your main public_html directory. It can have similar content, different content, or no content at all. That's completely up to you, since it is your "public face" on the web here at UD. It is not necessary to have a link into your CISC181 home page, but you can if you want.
  6. Now that you have a public_html subdirectory, and a public_html/cisc181 subdirectory, we need to also create two more levels: a public_html/cisc181/files level, and a public_html/cisc181/files/lab00 directory. (Again, you'll use a series of "mkdir" and "cd" commands to accomplish this.) In these two directory levels, we will NOT put any index.html files. That way, when you go to it on the web with the command:
    http://copland.udel.edu/~userid/cisc181/files/
    OR
    http://copland.udel.edu/~userid/cisc181/files/lab00
    a directory listing will come up. You will put one file into the "files/lab00" directory, called "collegeDat.txt". It should follow the format we discussed in lecture this morning. Here is an example to follow:
    University of Delaware
    udel
    Newark, DE
    Blue Hens
    1743
    
    Make sure you can see this file on the web. You might need a chmod command to fix it up so that folks have permission to see the file in a web browser. A useful command is:
    chmod -R a+rx ~/public_html
    
    That command says "recursively, set the public_html subdirectory of my home directory to be readable and executable by everyone". It basically makes the entire directory tree rooted at ~/public_html available. (Remember that command: it will likely be on the exam!)

    Note: your lab00.cc, lab00.dat, and lab00.txt files do NOT go in your web space; only your collegeDat.txt file. Also, your collegeDat.txt file does NOT get submitted via WebCT.

Part Two: Anderson Chapter 34

Sections 34.1 through 34.6

  1. First, to refresh your memory, skim over sections 34.1 through 34.4 in Anderson; this is what you went through last week in lab.
  2. Now, read over sections 34.5 and 34.6, type in recip.cpp (note that C++ files can end in either .cc, or .cpp), and compile it and run it.

    You should notice a problem with the program. See if you can figure out why it does not compute reciprocals correctly, and then fix the program.

    Once it is fixed, create a script called recip.txt of the corrected program that includes a program listing ("more recip.cpp"), a compile ("g++ recip.cpp", or "CC recip.cpp") and a run (./a.out).

    Your TA will tell you whether he prefers you to hand this in on paper, or via WebCT submission.

Sections 34.7 and beyond

These sections will be covered in a future lab; you'll need a little extra information to get those to work on the local systems here at UD. So you are advised to hold off on those for the time being.

Part Three: Programs from Lab Manual Chapter 1

Complete lab exercises 1, 2 and 3 from pages 19 through 30 of your lab manual, and the debugging exercise from p. 31-32.

For each of these exercises, you should complete the programming part. You are not required to complete the last section, labelled "Follow-up Questions and Activities". However, if you want to complete this, it would be a great way to study for future exams; I might take exam questions from these sections. If you do complete that part, you don't have to turn it in, but you can show it to your TA or to me during office hours if you want to know whether your answers are correct.

For each of the programs in this section, there is a partially completed program provided for you in the text. You don't have to type this in; instead, you can just copy it either from the web, at the following link:

http://copland.udel.edu/~pconrad/cisc181/04S/labs/lab01/
or, you can copy it using the following Unix command, which will copy the files into your current directory (note the "space" followed by a "dot" at the end of the command; that is very important!)
cp ~pconrad/public_html/cisc181/04S/labs/lab01/*.cpp .
For each of the programs, produce a script file where you
  1. list the finished program (with "cat programName.cpp" or "more programName.cpp"),
  2. compile the program with either CC or g++
  3. run the executable for the program one or more times. (e.g. with ./a.out.) (See instructions below on how many times is necessary.)
Name your script files according to the program names. The program names are
debugging01.cpp 
digits.cpp     
multiples.cpp  
numbercompare.cpp     
so, name your script files:
debugging01.txt 
digits.txt
multiples.txt  
numbercompare.txt     
Submit these files by WebCT. If your TA asks for a printout, please also print them out and turn them in. (See lab00 instructions online for details of how to get printouts.) Be sure that your name and your section number appears in a comment inside each of your C++ programs!

(But... don't EVER include your student number in anything you submit; this leaves you open for identity theft! Just your name and your section number is sufficient.)

How many times do I need to run each program?

When demonstrating runs of a program for this class, or any computer science class, keep the following in mind.

If the program has different kinds of output for different runs, be sure you include several runs that test the different kinds of output. An example of that is the debugging exercise on p. 31, where there are three different things the program might do, depending on whether x < y , x > y , or x ==y . In this case, your output should test all three cases, which means three different runs of the program. In this and all future labs, figuring out how many runs to do is part of the assignment. Points may be deducted if you don't show sufficient runs. Ask your professor or your TA if you are not sure.

Note that you also need to keep the amount of output reasonable; showing 20 runs just to be "safe" when three would suffice is not reasonable.

Finishing up: What to turn in for this lab

  1. Be sure that you have complied with all the steps in the web page section. There is nothing to turn in there; your TA will just check for it online.
  2. Be sure that you have completed a recip.txt script file containing a "corrected" copy of the recip.cpp program from Anderson section 34.5. Show that your file handles several different reciprocals correctly.
  3. Be sure you have completed all four of the required exercises from the lab manual (you should end up with four more script files.)
  4. Upload all five of your script files to WebCT and submit them. Your TA might also ask for a print out of one or more of the files.
  5. Grading:

Next Steps:

Do your reading assignment (found on the Calendar in WebCT) and complete the "prelab exercises" in the Lab manual for Chapter 2 before coming to lab next week (2/25/04.)

Also, begin to think about how we might read the contents of collegeDat.txt into C++ variables.

In next week's lab, among other things, we'll look at all the other programs in A34 (Anderson, Chapter 34.) So if you want to get a head start, type in and run all of those. Of particular interest is "separate compilation", the topic of 34.11 through 34.17.

You might also begin to look at either Chapter 14 (vi) or Chapter 15 (emacs.) You'll be responsible on the exam for (at least) all the contents of either one or the other of these two chapters (you'll have a choice of vi questions or emacs questions; I'll try to make the questions as similar as possible.)


Phillip T Conrad
Last modified: Tue Feb 17 21:45:32 EST 2004