1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
photoshop1234 [79]
3 years ago
8

The birthday paradox says that the probability that two people in a room will have the same birthday is more than half, provided

n, the number of people in the room, is more than 23. This property is not really a paradox, but many people find it surprising. Design a Java program that can test this paradox by a series of experiments on randomly generated birthdays, which test this paradox for n = 5, 10, 15, 20, ..., 100.
Computers and Technology
1 answer:
poizon [28]3 years ago
4 0

Answer:

The Java code is given below with appropriate comments for explanation

Explanation:

// java code to contradict birth day paradox

import java.util.Random;

public class BirthDayParadox

{

public static void main(String[] args)

{

   Random randNum = new Random();

   int people = 5;

   int[] birth_Day = new int[365+1];

   // setting up birthsdays

   for (int i = 0; i < birth_Day.length; i++)

       birth_Day[i] = i + 1;

 

   int iteration;

   // varying number n

   while (people <= 100)

   {

       System.out.println("Number of people: " + people);

       // creating new birth day array

       int[] newbirth_Day = new int[people];

       int count = 0;

       iteration = 100000;

       while(iteration != 0)

       {

           count = 0;

           for (int i = 0; i < newbirth_Day.length; i++)

           {

               // generating random birth day

               int day = randNum.nextInt(365);

               newbirth_Day[i] = birth_Day[day];

           }

           // check for same birthdays

           for (int i = 0; i < newbirth_Day.length; i++)

           {

               int bday = newbirth_Day[i];

               for (int j = i+1; j < newbirth_Day.length; j++)

               {

                   if (bday == newbirth_Day[j])

                   {

                       count++;

                       break;

                   }

               }

           }

           iteration = iteration - 1;

       }

       System.out.println("Probability: " + count + "/" + 100000);

       System.out.println();

       people += 5;

   }

}

}

You might be interested in
Companies that develop software for sale are called software ____.
yanalaym [24]
Hello <span>Loveworld4058 
</span><span>
Answer: Companies that develop software for sale are called software vendors.


Hope This Helps
-Chris</span>
4 0
3 years ago
If we use the square wave to transmit digital data (0s and 1s), what will be the data rate. Note data rate is the bits per secon
Nesterboy [21]
The maximum bit rate
6 0
1 year ago
______________ CRM supports traditional transactional processing for day-to-day front-office operations or systems that deal dir
Elina [12.6K]

Answer:

Explanation:

the answer is yes

3 0
3 years ago
A CIDR block contains the following subnets with the IP addresses of 192.168.68.0/22 192.168.69.0/22 192.168.70.0/22 192.168.71.
Dafna1 [17]

Answer:

Yes there is a problem.

Explanation:

Yes there is a problem.

Looking at /22, the host part has 10 bits(right most 10 bits). The subnet mask is:

1111111.11111111.11111100.00000000

The first IP address which is 192.168.68.0 in binary form:

11000000.10101000.1000100.00000000

Here all the 10 bits of host part are 0's. Hence it is a valid network IP address.

192.168,68.0 - This is avalid subnet id

The Next IP address 192.168.69.0 in binary form:

11000000.10101000.1000101.00000000

Here all the 10 bits of host part are not 0's. Hence it is not a valid network IP address for /22 cidr.

Moreover this address lies in the first subnet - 192.168.68.0, which has host addresses in the range of 192.168.68.1 to 192.168.71.254

Hence other IP addresses 192.168.69.9/22, 192.168.70.0/22 and 192.168.71.0/22 lies n the subnet 192.168.68.0/22.

4 0
3 years ago
Write a programto add two fractions and display the
klemol [59]

Explanation:

Program to add two fractions

Add two fraction a/b and c/d and print answer in simplest form.

Examples :

Input: 1/2 + 3/2

Output: 2/1

Input: 1/3 + 3/9

Output: 2/3

Input: 1/5 + 3/15

Output: 2/5

5 0
3 years ago
Other questions:
  • What is the opening page of a website called?
    9·2 answers
  • Who invented the Graphical User Interface (GUI)?
    5·1 answer
  • A popular use of cd-rw and cd-r discs is to create audio cds. what is the process of copying audio and/or video data from a purc
    11·1 answer
  • What is the main purpose of cutting plane line arrows?
    7·1 answer
  • The amount of data produced worldwide is increasing by ___% each year.
    5·1 answer
  • The architecture in which the database resides on a back-end machine and users access data through their workstations is
    5·2 answers
  • Create a program that calculates the tip and total for a meal at a restaurant. Type the code into an IDLE IDE editor window and
    5·1 answer
  • Make a webpage that shows news <br>​
    7·1 answer
  • Cómo se llaman los robots que se utilizan para la exploración espacial, en medicina, en la industria, en la agricultura, los que
    13·1 answer
  • Consider the following code:
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!