Well, the obvious (and only reliable answer is "ask your teacher why s/he is 'unhappy about the variables" ( simple letter names? descriptive names are better).

This is the 3rd thread you've begun with the same homework problem. And this time you've posed a question whose answer we can only guess at (you haven't identified your teacher, and even if you had, the Monastery's psi machine is down for an upgrade).

At least as bad, this is basicly the same code you posted previously, minus the previous assignments re add, subtract, etc -- since those were useless, it's good that they're gone. But you're still choping data from the terminal, when you should be chomping it, despite very clear advice to use chomp in this thread and yesterday's ...and you need to read the docs so you understand the difference. See chop and chomp.

Afterthought: numbering the choices when you don't intend to accept numeric replies is a bad idea: you may confuse the user -- "er, ah, um; should I enter '1' or 'add'?... which leads, if you think about it to a whole bunch of other improvements you could make: testing the input to see if it's numeric when numeric is appropriate; testing to see if it's alpha and one of the acceptable choices for the operation-to-perform input; maybe using a dispatch table so you can easily (and compactly) accept either '1' or 'a' or 'add' to determine the operation... and on and on....

But first, you've got to pay attention to advice here; learn to search the documentation; and speak up when the teacher says something you don't understand.


In reply to Re: how to program my program to add random numbers? by ww
in thread how to program my program to add random numbers? by rse2

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.