Question: Can someone write javadoc style comments for this program? import java.util.Random; import java.util.ArrayList; public class birthdayparadox { public static void main(String[] args) { int numSimulations

Can someone write javadoc style comments for this program?

import java.util.Random; import java.util.ArrayList; public class birthdayparadox { public static void main(String[] args) { int numSimulations = 10000; int n = 5; Random random = new Random(); while (n <= 100) { int number_of_times_same_birthday_found = 0;

for (int i = 0; i < numSimulations; i++) { ArrayList birthdays = new ArrayList(); for (int j = 0; j < n; j++) { int bday = random.nextInt(365) + 1;

if (birthdays.contains(bday)) { number_of_times_same_birthday_found++;

break;

} else { birthdays.add(bday);

}

}

}

double estimated_prob = (double) number_of_times_same_birthday_found / numSimulations; System.out.println("Number of people with same birthdays " + n + ", probability is " + String.format("%.2f", estimatedprobability * 100)+"%");

n += 5;

}

}

}

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!