CS 101 Laboratory Programming Assignment Ten

For this assignment you may take your choice of one of three projects: Data Analysis, Privacy Encryption, or DNA Pattern Matching. Just do one of the three.

Data Analysis Program: Linear Fit

Write a program to read a data file of ordered pairs of floating point data (x, y) and find the slope (m), y-axis intercept (h), and standard estimate of error (s) of the best fit line. The equations you need to use are:




The input data file should be in ascii. The first line of the file should be the number of data points (pairs of coordinates x and y). The remaining lines should each have two numbers separated by a space. You can create these files for testing your program using a text editor. The program should prompt the user for the input file specification and should be able to read files from any drive.

Privacy Encryption and Decryption

Encryption is used to communicate in secret so that only the intended reipients of a message may understand it. One encryption scheme is discussed in our text on pages 561 and 562.

Write a program to encode and decode message files using a secret key known only to the sender and recipient. The key may be kept in a file on disk or may be entered by the user (sort of like a password). Note that the program example in the text (Program 9.15) will not meet this requirement because the key is hard coded into the program.

You are encouraged to invent your own encryption scheme. If you use an existing scheme, be sure to attribute your source properly. Here is a sample message file that you may use to test your program.

DNA Pattern Matching

Deoxyribonucleic acid (DNA) sequences form the genetic patterns of all known living things. These sequences are over a four-letter alphabet {A, C, G, T}. Write a program that asks the user for a DNA pattern (sequence). The user can either input the pattern from the keyboard or may indicate a text file to read the pattern from. Then the program should read a text file containing a long sequence of DNA and see how many times the DNA sample contains the pattern. It should store the starting point in the DNA whenever the pattern is found and should show the results on the screen.

For example, the following 24 symbols represent a fragment of HIV:

CCCATTAGCCCTATTGAGACTGTA
You may create your own DNA sequence files or you may use this one with ten thousand characters.

You have two weeks for this programming assignment. It is assigned in week 13 and is due in week 15 (Monday, April 26 through Friday, April 30).



This page established March 17, 1999; last updated April 13, 1999.