#!usr/bin/perl @pence=qw(5 10 20 50); @notels=qw(5 10 20 50); $note = $notes[0]; $coin = $pence[0]; sub pence{ print "How many $coin pence pieces do you have? "; $num=<STDIN>; chomp $num; $res = ($coin * $num)/100; } sub notes{ print "How many £$note notes do you have? "; $num=<STDIN>; chomp $num; $res = ($note * $num); } $coin = $pence[0]; &pence; $five=$res; $coin = $pence[1]; &pence; $ten=$res; $coin = $pence[2]; &pence; $twenty=$res; $coin = $pence[3]; &pence; $fifty=$res; $coin = 1; print "How many £1 coins do you have? "; $num=<STDIN>; chomp $num; $res = ($coin * $num); $coin = 2; print "How many £2 coins do you have? "; $num=<STDIN>; chomp $num; $res = ($coin * $num); $twopound = $res; $note=$notels[0]; ¬es; $fivenote=$res; $note=$notels[1]; ¬es; $tennote=$res; $note=$notels[2]; ¬es; $twentynote=$res; $note=$notels[3]; ¬es; $fiftynote=$res; $total = ($five + $ten + $twenty + $fifty +$pound + $twopound + $fiven +ote + $tennote + $twentynote + $fiftynote); print "You have £$total.\n";
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |