Data Structures and Algorithms in Java
Data Structures and Algorithms in Java
6th Edition
ISBN: 9781118771334
Author: Michael T. Goodrich
Publisher: WILEY
Question
Book Icon
Chapter 2, Problem 31P
Program Plan Intro

Ecosystem

Program plan:

  • Import the required java packages.
  • Create the class Animal,
    • Declare the array variable to fill the river.
    • Declare the constructor.
    • Define the print() function to read the size of river.
    • Define the printl() function to read the length of array.
    • Define the leftMove() function to fill ecosystem of river using bear, fish and null values with the help of random function.
    • Define the rightMove() function to fill ecosystem of river using bear, fish and null values with the help of random function.
    • Define the method check() to check the length of array elements and based on the value it calls the function to fill the ecosystem.
  • Define the main() function,
    • Declare the object for random() function.
    • Declare the object for Animal class.
    • Read the input using scanner class.
    • Fill the ecosystem with bear, fish and null values using the random() function.
    • Read the number of time steps.
    • Print the simulation ecosystem after each step.

Blurred answer
Students have asked these similar questions
What did you find most interesting or surprising about the scientist Lavoiser?
1. Complete the routing table for R2 as per the table shown below when implementing RIP routing Protocol? (14 marks) 195.2.4.0 130.10.0.0 195.2.4.1 m1 130.10.0.2 mo R2 R3 130.10.0.1 195.2.5.1 195.2.5.0 195.2.5.2 195.2.6.1 195.2.6.0 m2 130.11.0.0 130.11.0.2 205.5.5.0 205.5.5.1 R4 130.11.0.1 205.5.6.1 205.5.6.0
Analyze the charts and introduce each charts by describing each. Identify the patterns in the given data. And determine how are the data points are related.   Refer to the raw data (table):
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Programming Logic & Design Comprehensive
Computer Science
ISBN:9781337669405
Author:FARRELL
Publisher:Cengage
Text book image
C++ Programming: From Problem Analysis to Program...
Computer Science
ISBN:9781337102087
Author:D. S. Malik
Publisher:Cengage Learning
Text book image
Microsoft Visual C#
Computer Science
ISBN:9781337102100
Author:Joyce, Farrell.
Publisher:Cengage Learning,
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781305480537
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr