Description
Write a perl program that allows the user to enter a series of temperatures and display high, low, and average of temps. The required portion of the lab is through release 4; additional parts are for extra credit. Release schedule is a recommendation, rather than a requirement. If all functionality of release 4 is complete & working, I won't need to see earlier releases. However, if release 4 isn't fully funcional, partial credit will only be assigned if earlier releases are fully implemented.
Release 01
User enters temperatures one at a time. When finished, user enters 'stop'. Program displays low, high, and average temperatures for the data entered.
Enter temperatures: > 45 > 65 > 70 > stop High temp: 70 Low temp: 45 Average temp: 60
Release 02
Program should ignore non-numeric or unrealistic entries, and notify user that it has done so. E.g.,
Enter temperatures: > 45 > j3 ignored > 65 > 790 out of range > 70 > stop High temp: 70 Low temp: 45 Average temp: 60
Release 03
Program should allow user to clear values entered so far. E.g.,
Enter temperatures: > 555 > 444 > 333 > clear Values cleared > 70 > 80 > stop High temp: 80 Low temp: 70 Average temp: 75
Release 04
Allow user to enter one or more temperature(s) on any one line
Enter temperatures: > 10 > 20, 30, 40, 50 > 60, 70 > 80 > stop High temp: 80 Low temp: 10 Average temp: 45
Challenge (Bonus)
Allow user to specify temperature scale (with a default if unspecified). Output should indicate which scale is used.
Enter temperatures: > 78 f > 25 c > 60, 70, 22 c, 72 f > 80 > stop High temp: 80 Fahrenheit Low temp: 10 Fahrenheit Average temp: 45 Fahrenheit
Challenge (Bonus)
Allow user to change default scale:
Enter temperatures: > f Default scale is now Fahrenheit > 60, 65, 5 c, 74 > c Default scale is now Celsius > 18, 22, 21, 67 f > stop High temp: 23 Celsius Low temp: 5 Celsius Average temp: 20 Celsius
Helpful Hints (I Hope)
What is the problem with the following code block:
my $input = <>;
...
while ($input ne "stop") {
// do stuff
}
What is the problem with the following code block:
my $input = <>;
$input = chomp $input;
...
while ($input ne "stop") {
// do stuff
}
Next:
Some Helpful links:
