Question: Mouse! No~ (100 points) Assuming you have a cheese shop which has mouses problem. You,...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Question: Mouse! No~ (100 points) Assuming you have a cheese shop which has mouses problem. You, as the shop owner, would like to set up a list of traps to remove mouses. You don't know how many traps you need, so you decide to write a simulation for it. In this simulation, you have 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: Assuming 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. To get full marks, you need to: 1. Follow the printing format. (See the example output below) 2. Follow the simulation logic. 3. Correctly show the action and status. 4. The program should end when all mouses are removed. [Action] mouse-5 ate 1 grams of cheese [Status] cheese left: 13 [Action] mouse-3 ate 3 grams of cheese [Status] cheese left: 10 [Action] Cheese Machine add 10 grams of cheese [Status] cheese left: 20 [Action] mouse-5 get caught by trap [Action] mouse-3 get caught by trap [Action] Cheese Machine add 10 grams of cheese [Status] cheese left: 30 ===================== [Action] Store owner remove mouse-5 [Action] Store owner remove mouse-3 ======= [Status] Total cheese lost = 20 ==== [Status] cheese left: 10 [Action] mouse-4 get caught by trap [Action] mouse-5 ate 3 grams of cheese [Status] cheese left: 7 [Action] mouse-2 get caught by trap [Action] mouse-1 get caught by trap [Action] mouse-3 ate 3 grams of cheese [Status] cheese left: 4 [Action] mouse-5 ate 2 grams of cheese [Status] cheese left: 2 [Action] mouse-3 ate 2 grams of cheese [Status] cheese left: 0 [Action] Cheese Machine add 10 grams of cheese [Status] cheese left: 10 [Action] mouse-5 ate 3 grams of cheese [Status] cheese left: 7 [Action] mouse-3 ate 1 grams of cheese [Status] cheese left: 6 [Action] Cheese Machine add 10 grams of cheese [Status] cheese left: 16 [Action] mouse-5 ate 1 grams of cheese [Status] cheese left: 15 [Action] mouse-3 ate 1 grams of cheese [Status] cheese left: 14 ----------------- [Action] Store owner remove mouse-4 [Action] Store owner remove mouse-2 [Action] Store owner remove mouse-1 [Action] mouse-5 ate 1 grams of cheese [Status] cheese left: 13 ====== -------- Question: Mouse! No~ (100 points) Assuming you have a cheese shop which has mouses problem. You, as the shop owner, would like to set up a list of traps to remove mouses. You don't know how many traps you need, so you decide to write a simulation for it. In this simulation, you have 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: Assuming 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. To get full marks, you need to: 1. Follow the printing format. (See the example output below) 2. Follow the simulation logic. 3. Correctly show the action and status. 4. The program should end when all mouses are removed. [Action] mouse-5 ate 1 grams of cheese [Status] cheese left: 13 [Action] mouse-3 ate 3 grams of cheese [Status] cheese left: 10 [Action] Cheese Machine add 10 grams of cheese [Status] cheese left: 20 [Action] mouse-5 get caught by trap [Action] mouse-3 get caught by trap [Action] Cheese Machine add 10 grams of cheese [Status] cheese left: 30 ===================== [Action] Store owner remove mouse-5 [Action] Store owner remove mouse-3 ======= [Status] Total cheese lost = 20 ==== [Status] cheese left: 10 [Action] mouse-4 get caught by trap [Action] mouse-5 ate 3 grams of cheese [Status] cheese left: 7 [Action] mouse-2 get caught by trap [Action] mouse-1 get caught by trap [Action] mouse-3 ate 3 grams of cheese [Status] cheese left: 4 [Action] mouse-5 ate 2 grams of cheese [Status] cheese left: 2 [Action] mouse-3 ate 2 grams of cheese [Status] cheese left: 0 [Action] Cheese Machine add 10 grams of cheese [Status] cheese left: 10 [Action] mouse-5 ate 3 grams of cheese [Status] cheese left: 7 [Action] mouse-3 ate 1 grams of cheese [Status] cheese left: 6 [Action] Cheese Machine add 10 grams of cheese [Status] cheese left: 16 [Action] mouse-5 ate 1 grams of cheese [Status] cheese left: 15 [Action] mouse-3 ate 1 grams of cheese [Status] cheese left: 14 ----------------- [Action] Store owner remove mouse-4 [Action] Store owner remove mouse-2 [Action] Store owner remove mouse-1 [Action] mouse-5 ate 1 grams of cheese [Status] cheese left: 13 ====== --------
Expert Answer:
Related Book For
Fundamentals of Investing
ISBN: 978-0133075359
12th edition
Authors: Scott B. Smart, Lawrence J. Gitman, Michael D. Joehnk
Posted Date:
Students also viewed these programming questions
-
IMPLEMENTING JAVA THREAD Assuming that I have a cheese shop that has mouses problem. I would like to set up a list of traps to remove mouses. I don't know how many traps I will need, so I need to...
-
A small consulting company wants to make the switch to QuickBooks Online. All of their expenses are paid at the time they are incurred, so there is no need to track bills in the system. There is only...
-
Jay Bhattacharya and Kate Bundorf of Stanford University have found evidence that people who are obese and who work for firms that provide health insurance receive lower wages than workers at those...
-
For each of the following items, calculate the cash sources or cash uses that should be recognized on the statement of cash flows for Baldin Co. for the year ended December 31. 2016: a. Sales on...
-
Tyler, a single taxpayer, generates business income of $3,000 in 2019. In 2020, he generates an NOL of $5,000. In 2021, he generates business income of $1,000. In 2022, his business generates income...
-
Richmond Sporting Goods uses the LIFO inventory method and values its inven tory using the lower-of-cost-or-market (LCM) rule. Richmond Sporting Goods has the following account balances at May...
-
Target Corporation prepares its financial statements according to U.S. GAAP. Targets financial statements and disclosure notes for the year ended February 3, 2018, are available in Connect. This...
-
A.Discuss whether consumers receive utilitarian and/or hedonic value from this company's product. B.Describe this company's marketing strategy to create value for consumers.
-
Prepare a financial analysis. This takes a close look at two corporations, Bayer and Monsanto. Bayer is considering a bid for United States seed company Monsanto (Snider, 2016). For purposes of this...
-
A massless spring (with force constant k = 187 N/m)connects a wall and a block of wood. The system is initially atrest, with the spring unstretched. The block has mass M =59.6 g and is able to move...
-
Can someone walk me through why the remove button isn't working properly? It's suppose to remove the users input from the list (so if they list was made from Lisa Simpson, Harry Potter, and Clary...
-
How did railroads change America? Industrialization and Technological Innovation ? Discuss one positive and one negative consequence of American industrialization
-
1 . Gordon Company issued 1 0 0 options on September 1 0 , 2 0 2 1 with an exercise price of $ 1 0 and a vesting period of 2 years. On that date, its stock was trading at $ 1 0 per share and the fair...
-
The most successful and admired companies have distinct combinations of attributes that make them stand out from the competition. People respect organizations like Apple, and Google because of their...
-
Why can we say that technological innovation was just as significant in building American cities as it was in driving American industrialization? In what ways did the Civil War help American...
-
Use Excel VBA. Please answer as simply as possible! Thanks! 4) Hand calculation problem. Rearrange the equations to make them diagonally dominant. Hand solve using the Gauss-Siedel iterative method...
-
Which of the following is FALSE regarding the purchasing power parity (PPP). a. The PPP is a manifestation of the law of one price b. The PPP says that a country with a higher expected inflation can...
-
Why do most income stocks offer only limited capital gains potential? Does this mean the outlook for continued profitability is also limited? Explain.
-
Assume you are considering a portfolio containing 2 assets, L and M. Asset L will represent 40% of the dollar value of the portfolio, and asset M will account for the other 60%. The expected returns...
-
Describe put and call options. Are they issued like other corporate securities?
-
What statutory and mandatory professional pronouncements require a review to be published?
-
List two items that may be found in the operating section and two items that may be found in the financial review section of an OFR.
-
What statutory and mandatory professional requirements require directors to submit a report to shareholders?
Study smarter with the SolutionInn App