Question: Full code written in Java Write a method with the header: public int ranDateInMonth(String aMonth) This method should return a random day in aMonth. As

 Full code written in Java Write a method with the header:public int ranDateInMonth(String aMonth) This method should return a random day inaMonth. As 29 February occurs 4 times less frequently than any otherday in that month, if the argument is "February" the method should

Full code written in Java

Write a method with the header: public int ranDateInMonth(String aMonth) This method should return a random day in aMonth. As 29 February occurs 4 times less frequently than any other day in that month, if the argument is "February" the method should generate a random number between 0 and 3 (inclusive) and return a random number between 1 and 29 if the random number is 0 , and between 1 and 28 otherwise. Write a method with the header: public void createMeeting(int numAttendees) This method should first invoke clear on bdays and then add to bdays the number of random birthdays given by numAttendees. Each random birthday is a string in the form of a day and a month, e.g., "4 July", where the month is generated using the ranMonth method and the day is generated using the ranDateInMonth method. Write a method with the header: public boolean foundMatch() The method returns true if there is at least one repeated birthday in bdays or false otherwise. Hint: One way of checking this is to use an outer loop to get each birthday from the bdays list in turn and an inner loop that then looks through the rest of the list to see if there is a match. Write a method with the header: public double runSimulation(int numAttendees) The method requires an int local variable called count to count how many meetings with numAttendees people include at least one pair of people with a matching birthday. The method should first initialise bdays to an empty ArrayList. Then it should do the following 10,000 times: - create a meeting with numAttendees attendees, - if the meeting includes at least one matching birthday, increment the count variable, - reinitialise bdays to an empty ArrayList. The final value of count should tell how many of the 10,000 meetings had at least one matching birthday. Now use the expression: ( count / 10000.0)*100 to estimate the percentage of the time that a meeting of the given number of attendees will have at least one matching pair of birthdays. This value should be returned by the method

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!