Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a program BoysAndGirls.java that takes an integer command-line argument T

ID: 3541396 • Letter: W

Question

Write a program BoysAndGirls.java that takes an integer command-line argument T. In each of T independent experiments, simulate a couple having children until they have at least one of each gender. Use the results of the T experiments to estimate the average number of children the couple will have. Record and output the frequency counts for 2, 3, and 4 children, and also one count for 5 and above. Finally, output the most common number of children in a family (if there is a tie, print only the first most common number of children). As before, assume that the probability of having a boy or a girl is 1/2.


As T increases, we expect the average number of children per family to converge. Use BoysAndGirls to formulate a hypothesis as to what this average is. Run BoysAndGirls with T = 1, 10, 100, 100000 and 1000000 to watch it converge to a sufficiently accurate estimate.


Explanation / Answer

As T increases, we expect the average number of children per family to converge. Use BoysAndGirls to formulate a hypothesis as to what this average is. Run BoysAndGirls with T = 1, 10, 100, 100000 and 1000000 to watch it converge to a sufficiently accurate estimate.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote