Write a bluej project- birthday paradox

Assignment Help JAVA Programming
Reference no: EM13785173

The birthday paradox states that if there are 23 people in a room then there is a slightly more than 50:50 chance that at least two of them will have the same birthday. In this exercise you will write a BlueJ project (birthday_paradox) that will help us empirically test this non-intuitive result. Your project will have just one Java classBirthdayParadox. The details of this class are given below:

· BirthdayParadox.java
o The following fields:
§ int[] days;
§ int numPeople;
§ int times;

o A constructor BirthdayParadox(int numPeople, int numTimes)which takes as input parameters the number of people and the number of times the simulation is to be performed.

o int rndDay() // returns a random day i.e., a random integer from 1..365 (inclusive)

o int once() // perform the simulation once

o void run() // After creating an instance of a BirthdayParadox object using the above constructor invoke the run method to run simulation
Your constructor for BirthdayParadox will take two inputs: the number of people we are testing for and the number of times to repeat the experiment. For each run of the experiment your program will print the number of people it randomly generated before a birthday repeated. It will print the average number of people after completing all the runs. Note that, by default, the BlueJ terminal window will only show the last 50 lines of a program. To show all the lines that are output by your program in the BlueJ terminal window, choose Options and select Unlimited buffering.

Following are two sample outputs of the program:

Output for

1 ---> 65
2 ---> 17
3 ---> 26
4 ---> 32
5 ---> 17
...
96 ---> 47
97 ---> 27
98 ---> 15
99 ---> 22
100 ---> 24

Avg ---> 24.4

Output for

3 people and 200 simulations

1 ---> 89
2 ---> 40
3 ---> 98
4 ---> 36
5 ---> 38
...
196 ---> 79
197 ---> 54
198 ---> 87
199 ---> 144
200 ---> 83

Avg ---> 86.7

Reference no: EM13785173

Questions Cloud

Chocolate company net income : A customer that had an account receivable with the company in the amount of $10,000 called and said they could not pay on time. You, the CFO, told them they could pay it all back in 120 days, but they would need to pay it back with 5% interest. ..
What is the z-score for a state score of 226 : What percentage of the students scored below student in Verbal Skills - What percentage of the students scored above student in Mathematics?
Consist of legal and fiduciary-oversight-fund-raising : Responsibilities of a non profit organization's governing board consist of legal and fiduciary, oversight, fund-raising, and representation of constituencies and viewpoints. Address the fund-raising duties of the governing board
Meaning of the expression dress for success : Research, examine, and discuss five positive work habits that are essential to long-term career success. Also, discuss the meaning of the expression "Dress for success." What does this mean to you, and how should you dress for work?
Write a bluej project- birthday paradox : The birthday paradox states that if there are 23 people in a room then there is a slightly more than 50:50 chance that at least two of them will have the same birthday.
Identify an issue that needs to be addressed : You will conduct sufficient web research to select a specific criminal justice-related issue/problem that the management, administration, and/or leadership of a major criminal justice organization are, have, or should beaddressing. Identify an iss..
Explain the components of the market research report : Explain the components of the market research report. Include a company in your explanation and how the final report will be useful to that type of company.
Pros and cons of dsm diagnosis : The Diagnostic and Statistical Manual of Mental Disorders (DSM) was originally developed in 1952 to help doctors and counselors across the country standardize the classifications of mental disorders in the American population. Throughout the inter..
Phase of the contract management process : What are two major types of authority applicable to a contract manager/project manager? Briefly explain each of these authorities.

Reviews

Write a Review

JAVA Programming Questions & Answers

  Write a java program to prompts a user to enter information

Write a Java program prompts a user to enter demographic information

  Java programming-days alive calculator

The context for this assignment (all parts) is a ‘Days Alive Calculator' - a small desktop applicationfor calculating the number of days someone has been alive based on the date of birth and a seconddate, which may be today's date or some other date.

  The 7th test of credits

The 7th test of credits? this is the 7th test of credits? this is the 7th test of credits? this is the 7th test of credits?this is the 7th test of credits?this is the 7th test of credits?this is the 7th test of credits?this is the 7th test of credits..

  Implement a simple paddle ball game

Implement a simple paddle ball game. Paddle Ball Game Overview The paddle ball game is a simplification of the Pong game. In the Pong game, a ball is moving around the display, bouncing off walls.

  Uml exercise automated teller machine atmnbspbrief

uml exercise automated teller machine atmnbspbrief statement of purposean atm is an electronic device designed for

  Designing a program with a while loop

The section entitled "In the Spotlight", "Designing a program with a while loop" describes the requirements for a project at Chemical Labs, Inc. Write a letter to the Director of Engineering that describe your concerns, if any, regarding these re..

  Write a program in java that reads a file

Write a program in Java that reads a file of numbers of type int and outputs all the numbers to another file, but without there being any duplicate numbers.

  What makes a program easy to modify

Describe the order of magnitude of the code section using Big(O) notation and Explain the relationship between dynamic storage allocation and recursion.

  Implement the nested loops

The user has also already entered a mystery number they want the following series to calculate based upon their current numbers (also relatively logical in size).

  Robot preparing for competition

Create an event so that the skateboard can be controlled by game player

  How many numbers do you want to enter

Write a program that asks the user "How many numbers do you want to enter?" With that value, create an array that is big enough to hold that amount of numbers (integers).

  Depicts a model for recording flight and passenger

This assignment requires you to design, implement and test a program using Java features from the first half of the subject content. You are required to implement in Java all the classes presented in the conceptual model according the specificatio..

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd