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

  To report the amount of the fine

To report the amount of the fine, which is $25 for the first hour or pan of an hour that the car is illegally parked, plus $10 for every additional hour or part of an hour that the car is illegally parked

  Given the following data definition classpublic class exam

given the following data definition classpublic class exam private static int totalpublic static void settotalint t

  Write a program that assigns seats on an airplane

Prepare a program that teaches arithmetic to a young child. The program tests subtraction and addition. Write a program that assigns seats on an airplane.

  Write a java program that computes and prints the value

Write a Java program that computes and prints the value of 6!/5! using Scanner.

  Write the java code for an abstract class named account

Write the Java code for an abstract class named Account which has two data members; one for the account number and the other for the account balance (use information hiding). The Account class should include get and set methods for both data membe..

  Class should have a method that returns the average

Write a class named TestScores. The class constructor should accept an array of test scores as its arguments. The class should have a method that returns the average of the test scores.

  A game of tic-tac-toe

A game of tic-tac-toe, two players (one the computer) take turns marking an available cell in a 3 X 3 grid (a two dimensional array) with their respective tokens (either and X or an O). When one player has placed three tokens in a horizontal

  Determine the day of the week for new year''s day

This assignment contains a java project. Project evaluates the day of the week for New Year's Day.

  Allows the user to enter students names followed

Write a program that allows the user to enter students names followed by their test scores and outputs the following information(assume that the maximum nmber of students in the class is 50

  Design a single class that expresses the commonality

Design a single class that expresses the commonality of these concepts.

  Question 1a give explanation amp the significance of

question 1a give explanation amp the significance of enterprise java beans ejb in software development.b explain the

  Write a program that reads a list of real numbers.

Write a program that reads a list of real numbers. After the program ends it should print out only the unique numbers

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