If you interested in the operator interface more than the details of the algorithm, use of perl modules can simplify the progam and provide improved error reporting/recovery.
use strict; use warnings; use IO::Prompt::Hooked; use List::Util qw(max min sum); my %prompt_options = ( message => 'input a positive integer (or a negative integer to st +op)', validate => qr/^-?\d+$/, error => "Input must be a positive integer\n", escape => qr/^-\d/, ); my @input_array; push @input_array, $_ while (defined ($_ = prompt(%prompt_options))); die "No inputs were entered\n" if (!@input_array) ; print "\n\n\n"; print 'Highest input: ', max( @input_array ), "\n"; print 'Lowest input: ', min( @input_array ), "\n"; print 'average: ', sum( @input_array ) / @input_array, "\n";

This approach is wasteful of both computer time and memory, but neither should be a problem with the small amount of data that a human operator is likely to enter. The advantage is that this is easy to write and you can hve confidence in the computations done by the modules.

Bill

In reply to Re: Need help converting!!! by BillKSmith
in thread Need help converting!!! by reynoldswrap530

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.