|
CS 100 Introduction to Computer Science Lab 5 PERL: loops & subroutines Due: May 1 / 2 at midnight |
|
Task 1: Write a program to
add numbers from 1 to 1000 and then output the result.
Task 2: write a program to add
all the odd numbers that are in the range of 1 to 1000 and then output the
result.
Task 3: Write a program for
the following algorithm:
(1)
Step 1: take a number from the keyboard,
(2)
Step 2: if the number is great than 0, sum all the integers that are greater
than 0 and less than
or equal
to the given number, then output the result. If the number is less than or
equal to 0,
then
display the message “the number you input is not greater than 0!” to the screen
and
terminate
your program.
Task 4: Similar to Task 3.
But you need to use a subroutine for Step 2.
How to submit your programs?
Please email your programs
for the tasks to Jasper Lin by the due date. His email address is
jlin@mtholyoke.edu.
Make sure you codes work
correctly before you submit them.
Grading:
|
Task 1 (Proper use of the
for loop) |
10 points |
|
Task 2 (Proper use of for
loop, % operation) |
10 points |
|
Task 3 (Proper use of if –
else statement) |
10 points |
|
Task 4 (Proper use of
subroutines) |
10 points |
|
Overall Readability of the
codes (comments, indenting of code blocks, descriptive variable names, etc.) |
10 points |