Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Assuming that I have a cheese shop that has mouses problem. I would like to set up a list of traps to remove mouses. Idon't

Assuming that I have a cheese shop that has mouses problem.

I would like to set up a list of traps to remove mouses. Idon't know how many traps I will need, so I need to design a simulation for it using Java Programming.

In this simulation, A cheese machine which can generate 10 grams of cheese to a cheese container every 2 seconds. In addition, there are X number of mouses and Y traps.

Every second, a mouse will consume 1-3 grams from the cheese container. If cheese container does not contain any cheese, the mouse will wait for it. Before a mouse eating cheese, it will have 50% chance to get caught by a trap. Each trap can only catch one rat.

The trap can only be available again when the shop owner removes the caught mouse. Every 5 seconds, the shop owner will check the traps and remove all the caught mouses. Finally, after all the mouses are removed from the shop, your simulation needs to print out the total loss of cheese in grams. More details: Assume that a mouse would like to consume 3 grams of cheese, however, the container only has 1 gram left, then the mouse can only consume 1 gram of it. Each mouse has an integer number representing the id of the mouse. e.g., mouse-1 or mouse-3. Please print the divider "============" when the owner removed mouses for better readability. The cheese container starts with a default number of cheese.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts In Vector Analysis

Authors: Rashmi Rana

1st Edition

9353146410, 9789353146412

More Books

Students also viewed these Mathematics questions

Question

During Year 2: Pays employees' salaries totaling $80,000. LO1.

Answered: 1 week ago