|
CS 100 Introduction to Computer Science Lab 3 Introduction to PERL Due: April 10/11 at midnight |
|
Part I: Edit
a given PERL program with notepad and run it on Windows
Part II:
Write your own program in PERL
Part I:
(1). Edit the following code
with notepad and save it to file example1.pl.
To run the program on
windows, you need to navigate your computer to
locate your file then double click the file.
#!c:/Perl/bin/perl print "Hello Perl!\n\n"; print "This is my first program in
PERL!\n\n"; # the follow two lines
are used to keep the output of the program stays. print "\n\n Press ENTER To Exit !\n"; $tmpvar = <STDIN>;
(2). Edit the following code
with notepad and save it to file example2.pl.
Run the program.
#!c:/Perl/bin/perl #this program takes three
numbers and output the sum of the numbers. print "Please enter the first number: \n”; $number1 = <STDIN>; print "Please enter the second number: \n”; $number2 = <STDIN>; print "Please enter the third number: \n”; $number3 = <STDIN>; $sum = $number1 +
$number2 + $number3; printf (“The sum of three numbers %f, %f, and %f is %f
\n\n”, $number1, $number2,
$number3,$sum); # the follow two lines
are used to keep the output of the program stays. print "\n\n Press ENTER To Exit !\n"; $tmpvar = <STDIN>;
Part II
Task 1: Write a program to
display the following graphs on the screen.
(1)
#####
#####
#####
#####
#####
(2)
#
##
###
####
#####
Task 2: Write a program to
take 4 numbers and output the product of them.
How to submit your programs?
Please email your programs
for tasks in part II to Jasper Lin by the due date. His email address is
jlin@mtholyoke.edu.
Make sure you codes work
correctly before you submit them. (Do not submit the example codes.)
Grading:
|
Program for task 1 |
25 points |
|
Program for task 2 |
25 points |