Answered step by step
Verified Expert Solution
Question
1 Approved Answer
3 Taking Statistics on an OwlPopulation Fill in the following methods to collect statistics on the Ow1Population. - public double averageAge ( ) - calculates
3 Taking Statistics on an OwlPopulation Fill in the following methods to collect statistics on the Ow1Population. - public double averageAge ( ) - calculates and returns the average age of all the owls in the population. Note: This function returns a double, while an Owl's age attribute is of type int. Make sure you aren't rounding the average age to an int. - public Owl getYoungest() - returns the youngest Owl in the OwlPopulation. If no owl is found, return null. - public Owl getHeaviest() - returns the heaviest Owl in the OwlPopulation. If no owl is found, return null. - public String toString( ) - returns a summary of the population. The summary should include the name and age of the youngest 0wl, the name and weight of the heaviest 0w1, and the average age of the owls in the population. The exact format of the summary is up to you. Milestone 3: Make a main method in your OwlPopulation class and demonstrate your statistic collection working - construct OwIPopulation objects from the two files supplied and print the result of calling toString() on each object. So that you can determine the accuracy of your methods, the output for population 1 should look something like this (although formatting may differ depending on your implementation): The youngest owl is Owl1, which is 1 years old. The heaviest owl is Ow189, which weighs 9.9 pounds. The average age of the population is 45.0. Population 2 should look something like this: The youngest owl is Hedwig, which is 3 years old. The heaviest owl is Buckbeak, which weighs 96.87 pounds. The average age of the population is 32.88059701492537. Reflection: What are the time complexities of averageAge(), getYoungest(), and getHeaviest()
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started