If you are a course participant, please send the solutions to these exercises to firstname.lastname@example.org before or on Wednesday February 17, 2000. Note that the only the first three exercises are obligatory. When you submit your results, please include the Perl code you have written, the result of at least one test and the answers to the questions mentioned in the exercise.
Write a program that reads a number and prints the table for that number three times. Each of the three tables should be coded with a different iterative structure. The tables should look like this example for input 17:
1 * 17 = 17 2 * 17 = 34 3 * 17 = 51 4 * 17 = 68 5 * 17 = 85 6 * 17 = 102 7 * 17 = 119 8 * 17 = 136 9 * 17 = 153 10 * 17 = 170
So all the multiplication operators and equal-to signs should be printed exactly under each other.
Write a program that reads an arbitrary number of non-negative numbers and stops when a negative number entered. After that the program should print how many numbers were entered and what the average of these numbers is.
Note: the negative number is used as a stop sign. It does not have to be included in the count and the average.
Implement a mini expert system for determining whether people are rich or poor. It should ask the following questions:
The answers to the questions should be entered with 1 representing yes and 0 representing no. The program should respond with "You are a rich person." if both the first and the second question have been answered with yes. It should answer "You are a poor person." if the first three questions have been answered with no and one or two of the remaining questions have been answered with yes. In all other cases it should respond with "You are a middle-class person.".
This is a starred exercise which means that you may skip the exercise. Make this exercise only if you think it is interesting and you have some time left.
Write a Perl program that reads five numbers and prints them twice: once in ascending order and once in descending order. For example, if the program receives 82, 0, 27, 9 and 3 as input then it should print:
Ascending order: 0 3 9 27 82
Descending order: 82 27 9 3 0
Note: the program may not use lists (these will be introduced in week four).
In the puzzle
LEARN PERL- ----- HERE
each character represents a number (0-9). Different characters represent different numbers and H, L and P are not equal to zero. Furthermore the subtraction is correct. Write a Perl program that solves this puzzle. What solutions do you get?