Question: Rewrite the pond life program from Figure 13.10 so that the values declared at the start of the program are no longer constant. The programs
Rewrite the pond life program from Figure 13.10 so that the values declared at the start of the program are no longer constant. The program’s user should be able to enter values for all of these constants. Also, improve the program so that the fish are more realistic. In particular, the fish should be born at a small size and grow to some maximum size. Each fish should also have a weekly food requirement that is proportional to its current size.



FIGURE 13.10 The Pond Life Simulation Java Application Program // FILE: PondLife.java // A simple simulation program to model the fish and weeds in a pond import edu.colorado.simulations.*; // Provides Organism, Plant, Herbivore classes import java.util.Vector; public class PondLife { // Number of weeds in the pond public static final int MANY_WEEDS = 2000; // Initial size of each weed, in ounces public static final double WEED_SIZE = 15; // Growth rate of weeds, in ounces/week public static final double WEED_RATE 2.5; // Initial number of fish in the pond public static final int INIT_FISH = 300; // Fish size, in ounces public static final double FISH_SIZE = 50; // A fish must eat FRACTION times its size during one week, or it will die. public static final double FRACTION = 0.5; // Average number of weeds nibbled by a fish over a week public static final int AVERAGE_NIBBLES = 30; // At the end of each week, some fish have babies. The total number of new fish born is the // current number of fish times the BIRTH_RATE (rounded down to an integer). public static final double BIRTH_RATE = 0.05; // Number of weeks to simulate public static final int MANY_WEEKS 38;
Step by Step Solution
3.33 Rating (174 Votes )
There are 3 Steps involved in it
ANSWER Heres the rewritten program with user input for the initial values and with fish that grow and have a weekly food requirement proportional to their current size import javautilScanner import ja... View full answer
Get step-by-step solutions from verified subject matter experts
