Ahhh, I figured out my problem. The values in the hash were wrong. Thanks to all who responded.
How do I multipy the value of a hash with a scaler? Thanks
Here is my code. This is for an assignment I am doing for a class I'm taking. I'm supposed to Write a payroll calculator. Let the user enter email addresses and how many weeks each email address worked this pay period. After the user enters 'quit', print out a report of how much to pay each employee. Use the following chart to determine employee's pay:
The problem is I can't even get what I have so far to multiply the hash times number of weeks worked. Any idea 's as to why my multiplication line is not working would be greatly helpful. Thanks
my %emails = (gwbush => "\$19.95",
billc => "\$19.95",
igor => "\$19.95",
jdoe => "\$25.00",
maryp => "\$35.00",
bgates => "\$50.00",
joelg => "\$1.50");
my $ename;
my $weeks;
print "Enter Email address.\n";
print "\nPress 'q' to quit\n";
while (){
print "\nEmail?\n";
chomp ($ename = <STDIN>);
if ($ename eq 'q'){
print "Quiting program";
last;
}
print "Weeks worked? \n";
chomp ($weeks = <STDIN>);
print "\n$ename\t$emails{$ename}\n";
$emails{$ename} *= $weeks;
print "We owe $ename\t$emails{$ename}\n";
}
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: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.