Steps toward getting a useful answer:

It will be ineffective to just ask people to do your homework for you. But the primary reason for the ineffectiveness isn't that people here aren't willing to help. It's that us doing your homework is ineffective at helping you to master the subject matter. Since we're generally aware of that fact, and since this site is geared toward helping people in their quest for knowledge (as opposed to their need to turn in assignments on time), we're often hesitant to just provide the answer when there's little apparent effort. That's just not what we're all about here.

In the case of your problem, I would do this: I would create four variables. One to hold the lowest value entered. One to hold the highest value entered. One to hold the tally of all values entered. And one to keep track of how many values have been entered. I would initially set all the variables to hold 'undef'. Then I would start a loop. I would query for input. I would test for a blank line. Then I would chomp, test for min-ness and max-ness (setting a new min or max if necessary), I would add the input value to the tally, and I would increment the sample count. If I wanted to play it safe I would also reject any input that was non-numeric. After the loop ends I would take care of the math and print the output. Often if you think through the steps, the code becomes easy.


Dave


In reply to Re^2: beginner needs help by davido
in thread beginner needs help by bjohn

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.