Lab 07: More sophisticated loops Goals: - Understand array syntax - Manipulate array objects - Design solutions that involve more complex loops - Practice testing and documenting more sophisticated programs. 0. Exercises 4.41 - 4.59. 1. Enhance the LogAnalyzer class with a method calles busiestHours that returns a collection with the busiest hours of a day. This method is similar to the busiestHour method that you developed before, but busiestHours will return more than one hour in case there is a tie for busiest hour. 2. Exercises 5.1-5.20. 3. Extra credit Develop an application that can provide a client with an approximation of pi. The pi approximator application will approximate pi as follows: Consider a circle with radius r = 1, inscribed within a (the smallest possible) square. Notice that the area of the square, as = (2 * r) * (2 * r)= 2 * 2 = 4. Also notice that the area of the circle, ac=pi * r * r = pi * 1 * 1 = pi, precisely the value that we are after. Now consider the following idea: If we draw the square with the circle on it and "throw random darts" at them, ratio ac/as is the ratio of darts that fall in the circle. This ratio is of interest because pi = ac = ac / as * as = (ac / as ) * as = ratio_of_darts_that_fall_in_circle * 4. So this is our algorithm for computing pi: Compute the ratio_of_darts_that_fall_in_circle and then multiply by 4. The ratio_of_darts_that_fall_in_circle can be computed as follows: Think of the circle on the cartesian plane and centered at position (0,0). Generate a large number of random coordinates (x,y) with the x and y positions in [-1,1] // "dart" positions and keep track of the number of "darts" that fall in the circle //(x*x + y*y) <= 1 and the total number of "darts." You can compute the ratio_of_darts_that_fall_in_circle and then multiply by 4 at any time to approximate pi. The approximation improves as you "throw" more "darts." Pedagogical note: You have just done your first Monte Carlo simulation!