Lab04, CISC105 Summer 2005

Directions

Programs

  1. (10) Write a void function that takes two parameters---a total width and a number of stars/asterisks---and prints the number of stars on one line, right-justified within the total width. Call the function from a main program that demonstrates the function's abilities.

    Example output:

    Right-justify 5 asterisks in 10 spaces

         *****
    

    Right-justify 1 asterisk in 20 spaces

                       *
    
  2. (10) Write a function that takes two parameters---the original value and a scaling factor---and returns the scaled value. Call the function from a main program that demonstrates the function's capabilities.

    Example Runs:

    Enter a number: 3.5
    Enter a scaling factor: 30
    Scaled value: 105
    
    Enter a number: -1
    Enter a scaling factor: 20
    Scaled value: -20
    
  3. (30) Modify angle.c to be more general and to use some of the concepts we've learned since we originally wrote the program. In next week's lab, we'll put the above programs together to create a bigger program.

Creating a Web Page

Goal 1: Creating a personal web page (10)

  1. If you already have a personal web page on strauss (one that comes up when you type http://udel.edu/~userid, where userid is your UDelNet ID), then skip to the next goal (creating your CISC105 web page). Otherwise, cd into your ~/public_html directory.

  2. Use emacs to create a file in that special directory. The file must be named "index.html". The contents of that file should be something like the following:

    <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/cisc105">CISC105 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 CISC105 class. Right now it is pretty lame, but I hope to make it better later.

  3. After you save the file, you need to type in the following command:
    chmod a+rx ~/public_html/*

    This command makes all files and directories in your public_html directory accessible to all users on strauss, as well as all users on the World Wide Web. You need to repeat this command each time you add new files under public_html that you want users of the Web to be able to access.

    More details:The asterisk in the above command is a "wildcard" that matches every file name in the public_html directory. You can also use chmod on individual files and directories as shown in class. You need to repeat this command each time you add new files under public_html that you want users of the Web to be able to access.

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

    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 ~/public_html/*" command. If you did that, and it still doesn't work, check with your TA or with a classmate for help.

Goal 2: Creating a CISC105 web page (10)

  1. cd into ~/public_html/cisc105. Now, create an index.html file in this directory containing html code similar to the personal page.
  2. Now, add an image to your web page. Find an image on the Web (or from wherever you want) and copy it into your public_html/cisc105 directory. Then, put the image in your CISC105 Web page, using the HTML tag <img src="imagename.jpg">, where "imagename.jpg" is the (case-sensitive) name of your file.
  3. After you have created the index.html file and/or copied your image file into your public_html/cisc105 subdirectory, you may need to repeat the chmod a+r [filename] command to get the web page to come up when you use the URL http://udel.edu/~jsample/cisc105.

Goal 3: Why are you here? (30)

Several of you have mentioned that you're not sure why you have to take the course for your major. I, of course, believe that the course is just plain fun, so you shouldn't need a reason.

Computers and programming specifically have advanced all sciences. For example, researchers in other fields use computer programs to write simulations before performing expensive experiments in real-life. Computer programs are also used to process data quickly. Computer programming is a very useful skill!

Your assignment: Find at least two Web pages that discuss the connection between your major and computer science. (If you don't have a major, pick a potential major or find some sites about computer science that interest you.) Add these links to your cisc105 web page. Summarize what you learned from each link in a little blurb.

The goal of this assignment is not to learn HTML, but if you would like to learn a little more about HTML to format your page nicer, there are many resources available: You can find many, many more if you do a Google search.

Submission

You should have a total of 3 programs named lab04.1.c to lab04.3.c. Make a single script file (see lab00 for the instructions) where you cat, compile, and run each one in its final form (if it didn't compile, don't run it in the script - mark the place in the printed script file with a marker so it stands out).

Note: Cat, compile, and run each program in order! Do not cat all programs, then compile, etc.

Execute your program multiple times to show that you tested the program well.

Submission

Email the tar file to Gang by midnight on Wednesday (see lab00 for directions). Give the paper version to Gang at the beginning of your next lab. Clearly write at the top of your paper submission where Gang can find your web page.

Grading

Grading is as noted above for each program, and creating the web pages is worth 50 points for a total of 100 points. (Using UNIX, e.g., changing file permissions, is included in the 50 points.)
The "Creating a Web Page" part of this lab was adapted from Phill Conrad's lab.