Week-3-exercise 2-instruction

advertisement
Week3 Exercise2 calorieAdvisor_**.pl Demo
Your advisor, who is a nutritionist, asked to write a perl script that alert people on their calorie intake. You did an online search on the subject and
found the following information.
http://www.diabetes.org.uk/Guide-to-diabetes/Healthy_lifestyle/Managing_your_weight/Calorie_controlled_plan/?print=2
Food Category
Average calories per serving
Suggested servings for Women
Suggested servings for Men
Breads and cereals
90
5 servings, 450 cal
7 servings, 630 cal
Fruit and vegetables
45
5 servings, 225 cal
7 servings, 315 cal
Average meat/poultry
140
2 servings, 280 cal
2 servings, 280 cal
Average milk and dairy
75
3 servings, 225 cal
3 servings, 225 cal
Other
320 cal,
350 cal
Total
1500 calories
1800 calories
Write a program calorieAdvisor_**.pl (** stands for your initials)
Pseudocode:
Welcome user and state the purpose of the program
Ask the user to choose gender (F for female M for male or W for woman M for man)
Ask the daily serving for each of the food categories
Multiply the number for each category by the average calories for servings
Check if the amount is bigger than the daily recommended calories for the gender
Print result to user
Algorithm: (in the absence of the elsif and else statements i.e. using only simple if block!)
Print Welcome message
Print Daily calorie intake calculation depends on gender
Print Type W if you are a Woman or M if you are a Man and press enter
Accept user input in a variable called gender
Print Type the number of Breads and cereals servings per day
Accept user input in a variable called breadCrealServings
Print Type the number of Fruit and vegetables per day
Accept user input in a variable called fruitVegetableServings
Print Type the number of Average meat/poultry per day
Accept user input in a variable called meatPoultryServings
Print Type the number of Average milk and dairy per day
Accept user input in a variable called milkDairyServings
Set a flag variable to store test outcome and set it to 0
Calculate total calories and save in a variable called totalDailyCalories
If gender is male
if totalDailyCalories > 1900
Print exceeded calories consult dietician
Set flag to 1
if totalDailyCalories < 1700
Print Calorie intake under daily recommended values consult dietician
Set flag to 1
If flag == 0 # if neither of the above is true flag will be zero
Print Calorie intake within normal range, keep up your current food regimen
Week 3 Exercise 2.2 ()
Write a program tempConvert_**.pl that converts Fahrenheit to Celsius and vice versa
(ask user which one he/she want to do and do it!)
Week3 Exercise 2.4 (Homework A)
Write a program calculateGrade_**.pl that Takes test-1(10%), midterm(25%), test-2(15), final exam(50%)
grades for Biochemistry class and assigns grades based on the total of the grades.
( MUST USE this scale: https://people.sunyit.edu/~boylank/scale.html)
1
Week3 Exercise 2.4 (Homework B)
Write a program aridityIndex_**.pl that tells the Aridity level of a region based on the Köppen and Geige formula
In the following link:
http://en.wikipedia.org/wiki/Aridity_index (Use the scale at the bottom of the web page)
Week3 Exercise 2.5 (homework C)
Your advisor, who advised you to take Gen712/812 asked you to whip up a perl script that can calculate the molecular weight of a
short nucleotide (18-24 bases long) so that the DNA synthesis company's yield claims can be tested against the Nano Drop DNA
quantitation instrument readings. You did an online search on the subject and found the following information.
http://www.lifetechnologies.com/us/en/home/references/ambion-tech-support/rna-tools-and-calculators/dna-and-rna-molecularweights-and-conversions.html (The main ideas are pasted below for your convenience)
Nucleic Acid Molecular Weight Conversions
Exact M.W. of ssRNA (e.g., RNA Transcript)
Formula #1: M.W. = (An x 329.2) + (Un x 306.2) + (Cn x 305.2) + (Gn x 345.2) + 159
An, Un, Cn, and Gn are the number of each respective nucleotide within the polynucleotide.
M.W. calculated is valid at physiological pH.
Addition of "159" to the M.W. takes into account the M.W. of a 5' triphosphate.
Exact M.W. of ssDNA (e.g., Oligonucleotides)
Formula #2: M.W. = (An x 313.2) + (Tn x 304.2) + (Cn x 289.2) + (Gn x 329.2) + 79.0
An, Tn, Cn, and Gn are the number of each respective nucleotide within the polynucleotide.
Addition of "79.0" to the M.W. takes into account the 5' monophosphate left by most restriction enzymes. No phosphate is
present at the 5' end of strands made by primer extension.
Approximate M.W.'s of Nucleic Acids
Formula #3: M.W. of ssRNA = (# nucleotides x 320.5) + 159.0
Formula #4: M.W. of ssDNA = (# nucleotides x 303.7) + 79.0
Formula #5: M.W. of dsDNA = (# nucleotides x 607.4) + 157.9
You were so interested in the issue, you wanted to write a program (molWtCalc_**.pl) that would:
Prompt the user to choose calculation for
1. RNA Transcript
2. Oligonucleotides
3. Approximate M.W. of ssRNA
4. Approximate M.W. of ssDNA
5. Approximate M.W. of dsDNA
Your script :




asks the total Number of A, C, G and T or U residues (one per line) for choice 1 and 2
or just the total number of nucleotides for choices 3-5
Calculates the appropriate molecular weight and
prints the result to the user
Hints:
1. Assume the user is intelligent and will enter asked data correctly.
2. Follow the calorieCalculator.pl flow on pseudocode and algorithm development
and convert your algorithm into a perl script
2
Download