Ryan Dillinger wrote:
Hello,
I have written this script. I have a good understanding of all but line:
$return = ($end - $start) / $start * 100;
If I start with 1000, and end with say..900 or vise versa. You subtract
first then?
What do you expect as an result?
Thank You for your help!
#!/usr/bin/perl
use warnings;
$start = 0;
$end = 0;
$return = 0;
while () {
print 'Enter the starting price ';
chomp($start = <STDIN>);
print 'Enter the current price ';
chomp($end = <STDIN>);
if ($start eq '' or $end eq '') {
print "Either the purchase or the current price is missing\n";
next;
}
if ($start =~ /\D/ or $end =~ /\D/) {
if ($start =~ /\// or $end /\//) {
if ($start =~ /\// or $end =~ /\//) {
print "Enter prices as decimal numbers.\n";
next;
}
}
last;
}
$return = ($end - $start) / $start * 100;
if ($start > $end) {
print "Your investment has lost money\n";
}elsif ($start < $end) {
print "Your investment has made money\n";
}else{
print "Your investment lost money\n";
print "Your investment has broken even\n";
}
print "Your return on your money is: ";
printf("%.1f%%\n", $return);
--
Just my 0.00000002 million dollars worth,
Shawn
"For the things we have to learn before we can do them, we learn by doing them."
Aristotle
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
http://learn.perl.org/