CPE 101
Fall 2008
Laboratory 2


Due Date

Objectives

Resources

Ground Rules

You may work with a partner or you may work alone.  If you work with a partner, submit one set of programs at the end.  Ensure that both your names are on the program file as comments.

Part 1: Exploration - evalcoins.c

Follow all the directions in the exploration Evaluating Coins.

Part 2: Create a complete program

In this activity you will develop a complete C program that solves a simple sequential problem, the Granny Quilt Cost problem.  Name the source code file "grannyquilt.c"

Follow the steps in the process for how to build a program.

Demonstrate your executing program to the instructor before doing the handin process.

Part 3: Converting a FORTRAN program to C

If you found part 2 a little challenging, this section will give you more practice.
  1. Study this FORTRAN program that solves a simple engineering problem. . 
  2. First run the program on vogon.  Compile the program using this command:
    f90 seawater.f90
  3. Execute it by typing
    a.out
  4. Provide these sample data values.
    30  29.1
    35  28.6
    33
    The result should be 28.8.
  5. Convert the source code to C, and name your file seawater.c.
  6. Compile and execute it with the same input data and verify it produces the same results as the original program.
  7. Demo you program to your instructor.

Part 4: Submit your completed programs

Handin

  1. Submit your evalcoins.c seawater.c and grannyquilt.c using handin. To do this, you must do the following steps.
    1. Once on vogon (or the terminal in our lab), navigate to the directory where your files are located.
    2. Execute the handin command:
                  handin gradercst lab02 evalcoins.c seawater.c grannyquilt.c
      This command submits your files to the lab02 directory in your instructor's account.  .
    3. If you execute the handin command without a filename, it will report the files that you have submitted.
              handin gradercst lab02

Part 5: Create a printout of your program execution

There are many ways to create a hard copy of your executing program. 

Recommended:
  1. Compile and execute the program in the terminal window.
  2. Use the mouse to select the region of the display you want to print.
  3. Click the print icon on the toolbar, or select "Print" from the File menu.
  4. The Print dialog box will appear.  Make sure the radio button for "Selection" is chosen, then click OK.

Windows Alternate (this is if you installed jGRASP on your windows box, not recommended anymore.):
  1. Compile and execute the program with some alternate environment (editor and compiler).
  2. When the program finishes executing, don't close the output window.
  3. Using the mouse, right-click on the title bar.  A pop-up menu should appear.
  4. From the pop-up menu, select "Edit" then "Mark".
  5. Using the mouse, select the region of the display you want to print.
  6. Hit Enter. (This copies the selected text to the clipboard).
  7. Open Notepad or other text editor such as EditPad.
  8. Paste the text into the editor window.
  9. Select "Print" from the File menu.
Submit the printout to your instructor.