eoin has asked for the wisdom of the Perl Monks concerning the following question:
#To determine the pattern of fish reproducing #in a pond #Using the Chaos Theory &start(); ############################################################ sub start{ print "Welcome to the 'Fish in a Pond' chaos theory solution guide +.\n" . "Please enter the number of fish in the pond on the f +irst year:\n"; print "\n"; $nof = <STDIN>; print "\n"; print "Please enter the anual rate of increase: \n"; print "\n"; $roi = <STDIN>; print "\n"; print "For what period of time would you like the simulation t +o run for(in years): \n"; print "\n"; $yrs = <STDIN>; chomp($nof); chomp($roi); chomp($yrs); &confirm(); } ############################################################ sub middle{ $ans = $nof; $year = 0; print "Year $year. = $ans fish."; print "\n"; &calc(); } ############################################################ sub calc{ while($year <= $yrs) { $year = $year + 1; $i = $ans * $roi; $x = 1 - $ans; $ans = $i * $x; print "Year $year. = $ans fish. \n "; } } ############################################################ sub confirm{ print "The data that you have entered says: \n" . " * that there is $nof in the pond on the fisrt year. \n" . " * that the annual rate of increase is $roi. \n" . " * that the simulation will run for $yrs years. \n"; print " Is this information correct?(Y/N): "; $answer = <STDIN>; chomp($answer); if ($answer = "n") { &start(); } elsif($answer = "y") { &middle(); } else{ print "Please enter either Y or N. \n"; &confirm(); } } ############################################################
If everything seems to be going well, you obviously don't know what the hell is going on.
Edit by tye, add READMORE
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: A missleading sub
by Mr. Muskrat (Canon) on Jun 10, 2003 at 16:51 UTC | |
by eoin (Monk) on Jun 10, 2003 at 16:58 UTC | |
|
Re: A missleading sub
by Not_a_Number (Prior) on Jun 10, 2003 at 18:46 UTC | |
|
Re: A missleading sub
by LAI (Hermit) on Jun 10, 2003 at 16:52 UTC | |
|
Re: A missleading sub
by shemp (Deacon) on Jun 10, 2003 at 16:57 UTC | |
by eoin (Monk) on Jun 11, 2003 at 12:03 UTC | |
|
Re: A missleading sub
by Enlil (Parson) on Jun 10, 2003 at 16:52 UTC |