Assignment 3
Due Thursday 9/24 at the start of class
Read chapters 3 and 4 of the Learning Perl book.
Write a Perl program that does the following
-
Reads a list of numbers (on separate lines) until the user enters -1.
-
Prints the list of numbers entered by the user. Do not use a loop for this
part.
-
Prints the list of numbers entered by the user in reverse order. Do not use
a loop for this part.
-
Prints the largest number that the user entered.
-
Prints the smallest number that the user entered.
-
Prints the average of the numbers entered.
-
Prints all the numbers that are above the average.
-
Warning: if the user enters -1 as the first number, then the output should
only say that no numbers were entered. Do not calculate the largest, smallest
and average numbers for this situation.
Use the script command to create a listing
to be handed in. Include the source code and several runs of the program.
Here is an example of the output
Please enter a list of numbers (-1 to stop)
2
5
3
1
7
6
4
Here is the list you entered
2
5
3
1
7
6
4
Here is the list you entered in reverse order
4
6
7
1
3
5
2
Here is the largest number: 7
Here is the smallest number: 1
Here is the average: 4
Here are the numbers above the average
5
7
6