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
Create a Java program Ā  5.Ā Stand out, Fit in byĀ CodeChum Admin A good spy can always recognize another spy. No matter how good the disguise or how well they blend in, something about spies will always stand out and make themĀ unique. Ā  For your final exam in Spy school you have to distinguish spies that are hiding in plain sight and among the public. You're given a multidimensional array that shows the people in a certain area. A spy is found if there is at least one of the people that is unique from all the others. Ā  Inputs 1. Number of rows of the multidimensional array Ā  2. Number of columns of the multidimensional array Ā  3. Elements of the multidimensional array Each element is within the range: 0 <= n <= 10 Ā  Sample Output Enter the number of rows: 3 Enter the number of columns: 3 1 2 2 7 3 8 4 4 3 SPY Ā  Expected Output Enter the number of rows: 4 Enter the number of columns: 3 4 3 3 2 3 6 5 4 6 3 5 2 NONE Ā  Expected Output Enter the number of rows: 4 Enter theā€¦
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 that allows the user to enter an arbitrary number of integer grades from the keyboard. Each grade should be added to an ArrayList called grades. Stop inputting grades when -1 is entered. The program should then iterate through the ArrayList, calculate the average grade, and output it along with the minimum and the maximum grade value.
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