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
50 POINTS<br><br>Question linked in file below.
Ratling [72]

{{5,10,15,20},{25,30,35,40}} is answer where zero is not found.

<u>Explanation:</u>

This program finds zero in giving as arrays of value as a parameter. The program has two loop. One is a row of the array and the other is column loop for each row o an array. For loop is created with a  variable namer row and the loop ends with a length of the array of each row.

In side row for loop col loop is created and loop ends with each row-column length of cells. If data in each cell i.e (row, col)  calue is zero it returns true and the loop is terminated immediately.

In case if the value of the cell doesn’t found zero it never terminates the loop and continuous loop and returns a false value. Find Zero functions accept the two-dimensional array and check whether cell value is zero. If it is zero found return true otherwise it returns false.

7 0
2 years ago
Archie wants to optimize an XFS filesystem and minimize the chance of future corruption. Which of the following commands will co
svlad2 [7]

Answer:

The best answer is "B"

xfs_fsr

Explanation:

The is a typical format of the command to use:

xfs_metadump -o /dev/sdb1 /reviewxfs

6 0
3 years ago
Read 2 more answers
What are some common options to sort a mail merge recipient list?
Anni [7]

Answer:

by city

by ZIP code

by last name

4 0
2 years ago
Read 2 more answers
hãy soạn thảo một bản hợp đồng chuyển giao hoặc thu thập thông tin nhằm bán/ mua/ trao đổi thông tin/ tài liệu giữa hai tổ chức.
mariarad [96]

Explanation:

wuwhwhwhshahahabahsgsgagsgshshshsjeushsjsjsiajausudid

idirieieirieeie

iep

7 0
2 years ago
PLEASEEEE PLEASEEE HELPPPP
olga nikolaevna [1]

Explanation:

you need a better pic if possible, it's kinda hard to read the question.

4 0
3 years ago
Other questions:
  • Identify a major drawback of browsing web pages on mobile devices.
    15·1 answer
  • A 5-inch, f/10 telescope has a 2-inch eyepiece focal. Its magnifying power is: (PLEASE HELP)
    6·1 answer
  • Consider sorting n numbers stored in array A by first finding the smallest element of A and exchanging it with the element in A[
    13·1 answer
  • A statement describing both the requirements that must be met by a product or process amd the ways in which satisfaction of the
    8·2 answers
  • Hi whats airpods good for
    15·2 answers
  • What's the inputs and outputs in a kitchen?
    14·1 answer
  • While reviewing system logs, a security analyst notices that a large number of end users are changing their passwords four times
    13·1 answer
  • Write a statement to declare a variable x with data type int and initialise with the value 10​
    13·1 answer
  • Hey everyone please let my friends answer please?????? .
    12·2 answers
  • How can I master networking my home/business computer(s) - Tv's - iot devices and make the whole system as secure as possible?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!