OK, just to get you started, this one possible way (untested, but hopefully right) to do the beginning:
use strict; use warnings; print "Please enter three numbers separated by spaces (complete by hit +ting the enter key)\n"; my $user_input = <>; # get user input chomp $user_input; # removing trailing newline from us +er input my ($nr1, $nr2, $nr3) = split /\s+/, $user_input; # splitting + user input on spaces to get the 3 numbers print "The sum of the three numbers is equal to ", ($nr1 + $nr2 + $nr3 +), "\n"; print "The product ...
This is not really the way I would personally write such a program, but I tried to make it quite simple for a beginner like you to understand it. Hopefully you should be able to complete by yourself.

I asked the user to enter the three numbers on the same line because I was too lazy to ask 3 times for a number and and get the user input three times in a row, but if you haven't covered yet the split function, you might as well change it to three questions, three standard input captures and three chomp's, once for each of the 3 variables.

I also changed the name of your variables because $a and $b are special variables (used for sorting data) that it would be better not to use for other purposes, although this has probably no importance in the case of your assignment (but it would be better not to get into the habit of using them for something else). But, of course, if your instructor is asking you to use $a, $a and $c, do it in accordance to his or her wishes.

One additional advise: when you'll try to code the division ($a / $c) and the remainder of the division ($a % $b), check before that $c and $b are not zero (to avoid a division by 0 error).


In reply to Re: Simple Arithmetic Question by Laurent_R
in thread Simple Arithmetic Question by pcoady

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.