Rewrite the pond life program from Figure 13.10 so that the output is presented as a graph
Question:
Rewrite the pond life program from Figure 13.10 so that the output is presented as a graph in an applet window. The applet can use most of the same graphing techniques as the fractal applet from page 426 in Chapter 8. You should use different colors for graphing the populations of the weeds and the fish.
Transcribed Image Text:
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;
Fantastic news! We've Found the answer you've been seeking!
Step by Step Answer:
Answer rating: 57% (14 reviews)
import javaawt import javaappletApplet public class PondLifeApplet extends Applet private static fin...View the full answer
Related Book For
Question Posted:
Students also viewed these Computer science questions
-
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 user should be able to enter values for all of these...
-
A point travels along the x axis with a velocity whose projection vx is presented as a function of time by the plot in Fig.1.3. Assuming the coordinate of the point x = 0 at the moment t = 0, draw...
-
BACKGROUND You are an information analyst working for NEE. The company president has asked you to prepare a Quantitative analysis of financial, sales, and operations data to help determine which...
-
Build a circuit on a breadboard from the circuit diagram of the two loop-network circuits: www R
-
You plan to conduct a survey on your campus. What is wrong with selecting every 50th student leaving the cafeteria?
-
Which side is longest in the triangle with vertices A(1, 2), B(3, - 1), and C(5, 3)?
-
What do you think a focus on the customer will look like for companies in 2030?
-
Buil Corporation manufactures a single product. The standard cost per unit of product is as follows. Direct materials2 pounds of plastic at $6 per pound .......$12 Direct labor2 hours at $13 per hour...
-
How to calculate fair value of goodwill when total goodwill is $500,00?
-
Parry Corporation acquired a 100% interest in Sent Company on January 1, 2009, paying $140,000. Financial statement data for the two companies for the year ended December 31, 2009 follow: Required:...
-
A set is like a bag, except that a set does not allow multiple copies of any element. If you try to insert a new copy of an item that is already present in a set, then the set simply remains...
-
Extend the Organism object hierarchy from Section 13.3 so that there is a new class Carnivore as described in Self-Test Exercise 13 on page 710. Use the hierarchy in a model of life on a small island...
-
Let X 1 , . . . , X n be an i.i.d. sequence of Uniform (0, 1) random variables. Let M = max(X 1 , . . . , X n ). (a) Find the density function of M. (b) Find E[M] and V[M].
-
Discuss the strengths of corporate governance and assurance in the US.
-
The Solana power plant covers three square miles of the Sonoran Desert in Gila Bend, Arizona, about 70 miles from Phoenix. Whereas most solar installations rely on photovoltaic panels that convert...
-
Explain and discuss how the corporate reporting system dictates the content of the annual corporate report.
-
What are the approaches used by interest groups and organisations seeking to establish global acceptance of their proposals for standards or guidelines relating to corporate reporting?
-
Repeat 4.19.3 but this time determine which of the two options results in shorter time per instruction. Problem 4.19.3 Let us assume that we cannot afford to have three-input Muxes that are needed...
-
Let m, n be two positive integers. Prove that if m, n are perfect squares, then the product mn is also a perfect square.
-
A report from the college dean indicates that for the previous semester, the grade distribution for the Department of Psychology included 135 As, 158 Bs, 140 Cs, 94 Ds, and 53 Fs. Determine what kind...
-
Consider the inheritance of classes from Exercise R-2.12, and let d be an object variable of type Horse. If d refers to an actual object of type Equestrian, can it be cast to the class Racer? Why or...
-
Give an example of a Java code fragment that performs an array reference that is possibly out of bounds, and if it is out of bounds, the program catches that exception and prints the following error...
-
If the parameter to the makePayment method of the CreditCard class (see Code Fragment 1.5) were a negative number, that would have the effect of raising the balance on the account. Revise the...
-
Given the values of an unknown function f: RR at some selected points, we try to calculate the parameters of a model function using OLS as a distance and a ridge regularization: (if 15 0): a...
-
what is a 99.7% confidence interval for the change in IncrValue when Size increases by three acres? Dependent Variable: IncrValue Independent Variables: Size REGRESSION 2 Regression Statistics R...
-
In a game, you have 1/30 probability of winning $120.00 and a 29/30 probability of loosing $7.00. What is the expected value of your gain? (Hint: In the case of loss, a gain is negative.)
Study smarter with the SolutionInn App