CPE 101 Lab 2

Due Date

Objectives

Resources

Ground Rules

Part 1 is an individual activity.  The remainder of the lab is to be completed with a partner.  You must work together to complete the activity, but each must record their own lab notes in their notebook.  You will submit just one completed program; put both your names as authors in the program header.

Part 1: The Unix Computing Environment

Unix is a powerful operating system that you will use in many CSc classes so it's good to get familiar with it now.  One big benefit is that you can develop your software on Unix by connecting remotely from any internet-connected computer.  Thus you can complete your assignments from almost any computer in the world.  You can take a quick vacation to Bermuda and write your 101 programs from an Internet cafe on the beach.

It is crucial that you master the basic Unix commands needed to perform the programming tasks required in the course assignment.
 
Read the list of Required Unix Skills and work the Sample Scenario included.  Practice these skills on your own outside of class until you can complete the scenario in under ten minutes.

Complete the remainder of the lab with your assigned partner.

Part 2: Exploration - evalcoins.c

Follow all the directions in the exploration Evaluating Coins.


Part 3: 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.   Verify that both student names are included in the source file.

Use the handin command below:
    handin graderjd Lab02 grannyquilt.c

Part 4: Converting a FORTRAN program to C (optional)

If you found part 3 a little challenging, this section will give you more practice.
  1. It is not uncommon for a programmer to be assigned to convert a program from one language to another.  At first this sounds daunting, but many languages use the same principles and the differences are largely superficial.
  2. Study this FORTRAN program that solves a simple engineering problem.  With a little study you should be able to make a pretty good guess at how it works.  You'll notice some differences in the format of the read and print commands.  FORTRAN uses the "REAL" keyword instead of "float".  Beyond that it is very similar to C, Java, and other languages.
  3. A sample program execution looks like this (user input is underlined):
    For data entry, salinity units are parts per thousand (integer)
    temperature is degrees Fahrenheit (floating point).
    Enter first observed salinity and temperature: 30  29.1
    Enter second observed salinity and temperature: 35  28.6
    Enter new salinity: 33
    Interpolated freezing temperature: 28.80000
  4. You assignment is to convert the source code to a C program.  Name the file seawater.c.
  5. Compile and execute it with the same input data and verify it produces the same results as the original program.
  6. Submit your source file to handin.

Homework Programs
If you finish before the end of lab, complete the homework programs for Chapter 2.