1. Homepage
  2. Programming
  3. CS 245 Advanced Programming and Data Structures - Assignment 2 - Mouse Simulation

CS 245 Advanced Programming and Data Structures - Assignment 2 - Mouse Simulation

Engage in a Conversation
UWECCS245Advanced Programming and Data StructuresJavaMouse Simulation

CS 245: Advanced Programming and Data Structures CourseNana.COM

Fall 2024 CourseNana.COM

Assignment 2 CourseNana.COM

  CourseNana.COM

  CourseNana.COM

Assignment Task: CourseNana.COM

  CourseNana.COM

Mouse and Cat Simulation CourseNana.COM

This assignment will have you practice developing an OOP as a Java solution and have safe trip . You are to write classes that define a Mouse, Mouse.java, and a Cat, Cat.java. These classes will not have a main method. CourseNana.COM

Subsequently, develop Jave code on that will run a simulation, MouseSimulation.java, using your Mouse and Cat classes. This class will be your driver / runner to verify / test the project you’ve developed. CourseNana.COM

You are required to use those file and class names. CourseNana.COM

What are Mice? CourseNana.COM

They are tiny mammals with long tails, whiskers, and round ears! Only females can have a litter of baby mice. The gestation period for a mouse is 20 days on average. Female mice can get pregnant/breed again a week (7 days) after giving birth to a litter. Mice will breed for the first time at 40 days old. The probability of producing a female in a litter is equal to the probability of producing a male. Litter sizes can vary between 6 and 8. The litter size can be different for each pregnancy. CourseNana.COM


What are Cats?
CourseNana.COM

They are small mammals with long tails, claws, and whiskers! Cats hunt & eat mice. Each day, a cat goes hunting, with a chance of failure which is dependent on the number of cats and mice in the population. If a cat doesn’t eat for 5 days in a row, they will die. Only female cats can have a litter of kittens. The gestation period for a cat is 65 days on average. Female cats can get pregnant / breed again 4 months (120 days) after giving birth. Cats will breed for the first time at 180 days old. The probability of producing a female in a litter is equal to the probability of producing a male. Litter sizes vary between 2 and 10. Litter size can be different for each pregnancy. CourseNana.COM

  CourseNana.COM

What you need to do: CourseNana.COM

Create classes called Mice.java to model the Mouse and Cat.java to model the Cat. Your mice and cats will need a biological sex, age, and other fields to help you determine if it is pregnant, how many days of the gestation has passed, and how many days after the delivery of the last litter. You will also need to have methods to give the animals the ability to have variable numbers of offspring per litter. For each pregnancy, the litter size can vary. You will need to have some way of tracking when a cat last ate, and what happens when a cat eats a mouse. The chance of failure each day a cat goes hunting is equal to: CourseNana.COM

  CourseNana.COM

            failure rate (f) = CourseNana.COM

where the number of cats and mice are equal to the total values in the population on that specific day. CourseNana.COM

You will need to write a Client (Driver) Class called MouseSimulation.java that will simulate the growth of a population of mice and cats that starts with a given number of male and female animals at day zero. CourseNana.COM

The seed (initial) population of cats and mice will be read from an input text file (Assign-1_New-Input-Values.txt). In the input.txt file, the first integer will be the initial population of female mice, the second integer will be the initial population of male mice, the third integer will be the initial population of female cats, and the fourth integer will be the initial population of male cats. All animals in the seed population are adults (they can breed / become-pregnant immediately). The numbers will be tab delimited. Please remember to save the input.txt file directly in the IntelliJ project folder. CourseNana.COM

An example of input.txt is shown below: CourseNana.COM

            23   10   2   1 CourseNana.COM

            55   29   1   5 CourseNana.COM

            12    3    3   2 CourseNana.COM

In the example above, there are only three initial seed populations provided. The first row, for example, has an initial population of 23 female mice, 10 male mice, 2 female cats, and 1 male cat. Ensure that your solution can handle input files that may have a varying number of rows! CourseNana.COM

For each of these different seed populations, you must run different trials. CourseNana.COM

  CourseNana.COM

  CourseNana.COM

  CourseNana.COM

A single trial: CourseNana.COM

Increase the elapsed time by 1 day at a time and answer the following questions: CourseNana.COM

·      How many mice will there be produced after 1 year (365 days – should this be a constant?) CourseNana.COM

·      How many cats will be produced after 1 year (365 days – should this be a constant?) CourseNana.COM

To answer the question, you must have an approach of storing your mice and cats as you produce them. Use an ArrayList of type Mouse or Cat to do this. Seed this ArrayList with the initial population of mice and cats and add the new litters to it as they are produced. CourseNana.COM

Report the final population of total animals (Mice and Cats), female animals and male animals. (You need to return an integer array you used for tallying). CourseNana.COM

Now repeat the trial 10 times: CourseNana.COM

Your simulation should repeat this trial 10 times (This should be a constant).  Reporting the stats for each round (total mice, female mice, male mice, total cats, female cats, male cats). CourseNana.COM

Use a 2-D array to store the trial data (Example index 0 stores the array of tallies for the first trial). This organizes your data like a spreadsheet. The first column is the total mouse population, the second column is the female mouse population, the third is the male mouse population, and so on. Each row is a different trial. CourseNana.COM

Given the data for the 10 trials, report the average number of each animal (mice and cats) with its standard deviation, the average number of female animals with its standard deviation, and the average number of male animals with its standard deviation. The averages and standard deviations should report only have three digits after the decimal point. CourseNana.COM

Sample outputs below are based on the given sample input file above (remember there is randomness in determining sex, litter size, and predation so your output will vary. There will be another set of this output for each line in the input file): CourseNana.COM

    Starting with 23 female mice, 10 male mice, 2 female cats, and 1 male cat: CourseNana.COM

    Trial 0: 431 total mice; 201 females, 230 males. 20 total cats; 8 females, 12 males. CourseNana.COM

    Trial 1: 340 total mice; 173 females, 167 males. 24 total cats; 13 females, 11 males. CourseNana.COM

    Trial 2: 498 total mice; 256 females, 242 males. 17 total cats; 9 females, 8 males. CourseNana.COM

    Trial 3: 323 total mice; 162 females, 161 males. 27 total cats; 15 females, 12 males. CourseNana.COM

    Trial 4: 418 total mice; 209 females, 209 males. 19 total cats; 7 females, 12 males. CourseNana.COM

    Trial 5: 361 total mice; 179 females, 182 males. 24 total cats; 11 females, 13 males. CourseNana.COM

    Trial 6: 443 total mice; 235 females, 208 males. 18 total cats; 7 females, 11 males. CourseNana.COM

    Trial 7: 407 total mice; 212 females, 195 males. 20 total cats; 13 females, 7 males. CourseNana.COM

    Trial 8: 397 total mice; 204 females, 193 males. 23 total cats; 11 females, 12 males. CourseNana.COM

    Trial 9: 313 total mice; 159 females, 154 males. 28 total cats; 14 females, 14 males. CourseNana.COM

            CourseNana.COM

    Average number of mice: 393.100 with standard deviation of 55.623. CourseNana.COM

    Average number of female mice: 199.000 with standard deviation of 29.813. CourseNana.COM

    Average number of male mice: 194.100 with standard deviation of 27.541. CourseNana.COM

    Average number of cats: 22.000 with standard deviation of 3.578 CourseNana.COM

    Average number of female cats: 10.800 with standard deviation of 2.786 CourseNana.COM

The format of your output should match the above example. CourseNana.COM

Note: The values shown are only examples and may differ from what you get as output values. CourseNana.COM

Strategy: CourseNana.COM

·      Create your Mouse class. CourseNana.COM

o   Write your getter and setters and helper methods. CourseNana.COM

·      In your Driver create a Mouse object and test that your methods work correctly. CourseNana.COM

Once you have verified your Mouse  class works correctly, do the same for the Cat class, and then, CourseNana.COM

·      Write a method to run one trial of your experiment. CourseNana.COM

o   Populate your ArrayList of Mice and Cats with the correct number of seeds read from the input.text file. CourseNana.COM

o   For the number of days in your trial CourseNana.COM

§  Age each animal. CourseNana.COM

§  If it is pregnant – add a day to its gestational period. CourseNana.COM

§  If it can breed – let it breed. CourseNana.COM

§  If it can give birth – let it give birth (add litter to animal population) CourseNana.COM

§  See if it has a successful hunt that day. CourseNana.COM

§  Did it die? CourseNana.COM

·      Report/record the results of that trial in an integer array (print to verify then for final comment it out) CourseNana.COM

·      Repeat this trial 10 times recording each trial data in a 2dD array (print to verify then for final comment it out) CourseNana.COM

·      Report the averages and standard deviations. CourseNana.COM

·      Make sure your output is formatted like mine (see above). CourseNana.COM

  CourseNana.COM

Use meaningful names for methods and variables. Incorporate good horizontal and vertical indentation and whitespace in your code layout structure. CourseNana.COM

Include a header comment block at the top of all your .java files, and in that, include your full name and the purpose of that file. CourseNana.COM

  CourseNana.COM

Submission: CourseNana.COM

  CourseNana.COM

Please zip your IntelliJ Java project folder and submit the zipped file under the Assignment 2 on Canvas folder. To grade your work, I should be able to simply unzip your Java project, load it in the IntelliJ environment, and run it. CourseNana.COM

  CourseNana.COM

Academic Integrity Note: CourseNana.COM

  CourseNana.COM

Every student must work independently (strictly on their own) and must not collaborate or communicate with their peers (students) in CS 245 or other courses. CourseNana.COM

  CourseNana.COM

  CourseNana.COM

If you have any questions, please seek guidance from any of the two TAs and/or me. CourseNana.COM

  CourseNana.COM

Get in Touch with Our Experts

WeChat (微信) WeChat (微信)
Whatsapp WhatsApp
UWEC代写,CS245代写,Advanced Programming and Data Structures代写,Java代写,Mouse Simulation代写,UWEC代编,CS245代编,Advanced Programming and Data Structures代编,Java代编,Mouse Simulation代编,UWEC代考,CS245代考,Advanced Programming and Data Structures代考,Java代考,Mouse Simulation代考,UWEChelp,CS245help,Advanced Programming and Data Structureshelp,Javahelp,Mouse Simulationhelp,UWEC作业代写,CS245作业代写,Advanced Programming and Data Structures作业代写,Java作业代写,Mouse Simulation作业代写,UWEC编程代写,CS245编程代写,Advanced Programming and Data Structures编程代写,Java编程代写,Mouse Simulation编程代写,UWECprogramming help,CS245programming help,Advanced Programming and Data Structuresprogramming help,Javaprogramming help,Mouse Simulationprogramming help,UWECassignment help,CS245assignment help,Advanced Programming and Data Structuresassignment help,Javaassignment help,Mouse Simulationassignment help,UWECsolution,CS245solution,Advanced Programming and Data Structuressolution,Javasolution,Mouse Simulationsolution,