Reference no: EM131269973
Question:
Write a method to randomly populate the array of 25 integers with an integer value between 1 and 365 for each slot.
Write another method to check if two or more slots have the same integer. If so, then a match was found.
If not, repopulate the array and try again. Calculate average number of repopulations needed before a match is found.
If it takes on average, say, 5 tries to find a match, then the probability of 2 slots having same value on any random try is 1/5 or 20%.As owner of a new business, you have managed to get 25 loyal customers. In order to make them feel connected to your business, you want to send them cool birthday cards. Your best friend tells you that you should stock a couple of cards at least. You like to always do things Just in Time, and besides you may lose that extra card if you buy more than one. So you feel you should just buy one card before each birthday. Your friend (who took a basic probability class in college) insists that the probability of two people out of 25 having the same birthday (same date, different year) is higher than one would think. Neither of you has looked at the birthday dates of the 25 customers, and you are arguing this over lunch when you are vacationing for a week with your friend. You happen to have your laptop handy and decided to write a program to prove your friend wrong!
Please write a web page that calculates the probability that at least 2 people out of 25 have the same birth-date (different year is fine as long as they have the same date). Business implication: If the probability is higher than 50%, you'd probably want to keep a couple of cards handy.
Hints: We need to use the fact that there are 365 dates in a year. We need to use an array of 25 integers, where each integer is randomly generated between 1 and 365. We need to carefully study the code and email sent to us regarding calculating the probability of getting the same total if we roll two pairs of dice