Question: Write a simple program that accepts three numbers from the keyboard (one per line) and prints out the sum, average, product, smallest and largest of
Write a simple program that accepts three numbers from the keyboard (one per line) and prints out the sum, average, product, smallest and largest of the numbers.
Make your output follow the format requirements below. Write a very simple Perl program.
Remember that the <> operator reads an entire line, so you will need separate <> operators to read the three numbers. Remember that input from the the <> operator needs to have chomp applied to it.
Use numerical relational operators instead of string relational operators. Remember to have #!/usr/bin/env perl as the very first line of your program.
Use use Modern::Perl; in your program.
Try to follow the Perl Best Practices that weve discussed in class so far.
Do not use arrays or other libraries for this program.
Output the results of this program in the order: sum, average, product, largest, smallest. Format the output of only the average to have three significant digits after the decimal. All other values should be fully represented.
Use the labels
ADD, AVG, PRD, LRG, and SML before each corresponding value, followed immediately by a colon and then the value itself. See the sample output. Make sure to use the use Modern::Perl in your program.
Sample Program Run
Enter first number: 5
Enter second number: 1
Enter third number: 8
ADD:14
AVG:4.667
PRD:40
LRG:8
SML:1
Sample Program Run
Enter first number: 3.14159
Enter second number: -123412.2
Enter third number: 7
ADD:-123402.05841
AVG:-41134.019
PRD:-2713973.733786
LRG:7
SML:-123412.2
Sample Program Run
Enter first number: 6.0
Enter second number: 7.0
Enter third number: 6.5
ADD:19.5
AVG:6.500
PRD:273
LRG:7.0
SML:6.0
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
