Data Structures and Algorithms in Java
Data Structures and Algorithms in Java
6th Edition
ISBN: 9781119278023
Author: Michael T. Goodrich; Roberto Tamassia; Michael H. Goldwasser
Publisher: Wiley Global Education US
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
HistogramUse par(mfrow=c(2,2)) and output 4 plots with different argument settings.
(use R language)Scatter plot(a). Run the R code example, and look at the help file for plot() function. Try different values for arguments:type, pch, lty, lwd, col(b). Use par(mfrow=c(3,2)) and output 6 plots with different argument settings.
1. Draw flow charts for each of the following;a) A system that reads three numbers and prints the value of the largest number.b) A system reads an employee name (NAME), overtime hours worked (OVERTIME), hours absent(ABSENT) and determines the bonus payment (PAYMENT).
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