Docsity
Docsity

Prepare for your exams
Prepare for your exams

Study with the several resources on Docsity


Earn points to download
Earn points to download

Earn points by helping other students or get them with a premium plan


Guidelines and tips
Guidelines and tips

BIF 101 Lab 9: Algorithms and Programs for if and while Statements, Lab Reports of Bioinformatics

A lab assignment for a computer science course focusing on if and while statements in perl programming language. The assignment includes six programming tasks: averaging test scores, computing factorials, preventing division by zero errors, and avoiding infinite loops. Each task includes an algorithm and a perl program with testing instructions.

Typology: Lab Reports

Pre 2010

Uploaded on 08/18/2009

koofers-user-tvn
koofers-user-tvn 🇺🇸

5

(1)

10 documents

1 / 1

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
BIF 101 Lab 9 – if and while statements (ch 6)
Assigned: November 13, 2008
Due: November 20, 2008
For each of the following write (1) an algorithm and (2) a program to solve the given
problem. Test your program, demonstrating that it works and also demonstrating where (if
this is the case) and how it will fail (e.g. inputs are not what is expected). Paste your code
and the results of testing and results into a word file that you will submit via email.
1. avg1.pl
Input the number of test scores a user will type, and input that many scores, computing and
printing the average of the scores. Test the program with at least 5 scores and without
entering any scores. Describe what happens.
2. avg2.pl
Like avg1.pl but instead of having the user input the number of scores in advance tell the
user what to type when he/she is ready to quit (“sentinel value”). This program should also
check to see if there are no scores and should output a message – this will prevent a division
by 0 error.
3. fact.pl
Write a perl program that uses a while loop that inputs a value and computes and prints the
factorial of that value. Note that 0! is defined to be 1 as is 1! The factorial is the product of
the numbers from 1 up to a given positive integer. Make sure to test you program on a
negative number input, 0 input, and positive number input. Try typing a large positive
number – what happens? Note you may have to kill the running program with control-C.
4. fact2.pl
Like fact.pl but your program should check to make sure the number entered is > = 0 and <
= 7. The program should keep prompting the user until an appropriate value is entered.
Then the program should compute and print the factorial value.
5. loopy.pl
Choose one of the programs you have written with a loop and comment out a statement that
may cause the program to have an infinite loop. Run the program, explain what happens
and why the loop will never stop.
6. CGrich.pl
Create a program that implements the search for CG-rich regions in a DNA sequence
described in section 6.8.2 of the book. Explain how the program works.

Partial preview of the text

Download BIF 101 Lab 9: Algorithms and Programs for if and while Statements and more Lab Reports Bioinformatics in PDF only on Docsity!

BIF 101 Lab 9 – if and while statements (ch 6)

Assigned: November 13, 2008 Due: November 20, 2008

For each of the following write (1) an algorithm and (2) a program to solve the given problem. Test your program, demonstrating that it works and also demonstrating where (if this is the case) and how it will fail (e.g. inputs are not what is expected). Paste your code and the results of testing and results into a word file that you will submit via email.

  1. avg1.pl

Input the number of test scores a user will type, and input that many scores, computing and printing the average of the scores. Test the program with at least 5 scores and without entering any scores. Describe what happens.

  1. avg2.pl

Like avg1.pl but instead of having the user input the number of scores in advance tell the user what to type when he/she is ready to quit (“sentinel value”). This program should also check to see if there are no scores and should output a message – this will prevent a division by 0 error.

  1. fact.pl

Write a perl program that uses a while loop that inputs a value and computes and prints the factorial of that value. Note that 0! is defined to be 1 as is 1! The factorial is the product of the numbers from 1 up to a given positive integer. Make sure to test you program on a negative number input, 0 input, and positive number input. Try typing a large positive number – what happens? Note you may have to kill the running program with control-C.

  1. fact2.pl

Like fact.pl but your program should check to make sure the number entered is > = 0 and < = 7. The program should keep prompting the user until an appropriate value is entered. Then the program should compute and print the factorial value.

  1. loopy.pl

Choose one of the programs you have written with a loop and comment out a statement that may cause the program to have an infinite loop. Run the program, explain what happens and why the loop will never stop.

  1. CGrich.pl

Create a program that implements the search for CG-rich regions in a DNA sequence described in section 6.8.2 of the book. Explain how the program works.