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
Write a Java program that would resemble a payroll system. An input window which will accept the employee number and the number of days of rendered work. A 2d-arraylist that contains the employee number and the rate per day is to be searched and used to compute for the gross salary. Gross salary is computed by multiplying the number of days of rendered work by rate per day of the particular employee. If the gross salary computed is greater than 100,000 the tax is 20% of the gross salary, otherwise, the tax is 10%. Deduct the tax from the gross salary to get the net pay. Display the employee number, gross salary, tax deduction, and the net pay in an output window. Design your own input/output windows. ( USE OOP CONCEPT AND JOPTION)
Write a Java program (Hangman.java) to play the classic word game Hangman. In the game, a word is randomly selected from an array of possible words. Then, the user is prompted to guess letters in the word one at a time. When the user makes a correct guess, all instances of that letter in the word are shown. When all letters in the word have been guessed, the game ends and the score (number of missed guesses) is displayed. A user can play the game multiple times if they choose. Ā  Here is a sample run of a correct program (user input indicated by orange text):Enter a letter in word ******** > cEnter a letter in word c******* > rEnter a letter in word c******r > sĀ  Ā  Ā  Ā s is not in the wordEnter a letter in word c******r > tEnter a letter in word c****t*r > mEnter a letter in word c*m**t*r > tĀ  Ā  Ā  Ā t is already in the wordEnter a letter in word c*m**t*r > pEnter a letter in word c*mp*t*r > oEnter a letter in word comp*t*r > eEnter a letter in word comp*ter >ā€¦
A Memory Matching Game in java code with a 4x4 grid of Squares that when you click on a square it shows a number. It would have to be 2 of each number 1-8 and if the two squares that are clicked match then the squares stay on the grid. If they do not match after picking 2 squares they flip back over
Knowledge Booster
Background pattern image
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
Database System Concepts
Computer Science
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:McGraw-Hill Education
Text book image
Starting Out with Python (4th Edition)
Computer Science
ISBN:9780134444321
Author:Tony Gaddis
Publisher:PEARSON
Text book image
Digital Fundamentals (11th Edition)
Computer Science
ISBN:9780132737968
Author:Thomas L. Floyd
Publisher:PEARSON
Text book image
C How to Program (8th Edition)
Computer Science
ISBN:9780133976892
Author:Paul J. Deitel, Harvey Deitel
Publisher:PEARSON
Text book image
Database Systems: Design, Implementation, & Manag...
Computer Science
ISBN:9781337627900
Author:Carlos Coronel, Steven Morris
Publisher:Cengage Learning
Text book image
Programmable Logic Controllers
Computer Science
ISBN:9780073373843
Author:Frank D. Petruzella
Publisher:McGraw-Hill Education