I've posted a few other threads and all the help has been so helpful... I have another assignment and I need some more help.
For 9, I'm thinking that I should use a for loop and just do i-- for each time it runs through? After that just multiply the values together each time through the loop? To display the probability that no two n have the same birthday, does that mean that it's just displaying the multiplied numbers? Or does that mean I have to display all the different probabilities between each person... (assuming more than 2 people are entered).
For 10, I have no idea how to even get started... I'm assuming I have to define what probability each n value is?
Sorry I'm just a beginner ha I'm trying I promise.
For this problem, pretend that every year has only 365 days in it, and that nobody’s birthday is February 29. Assume further that two people have the same birthday if they become a year older on the same day every year. Thus, if two people were born on December 5, but in different years, they still have the same birthday.
Probabilities are decimal numbers between 0 and 1, inclusive. The probability that two people selected at random have different birthdays is 364/365, since the second person has 364 birthday possibilities that are different from that of the first person. If we add a third person, we can figure the probability that none of the three have a common birthday by computing the probability that the third person’s birthday is different from those of the other two, and then multiplying this number by 364/365, which is the probability that the first two don’t share a birthday. The probability that the third has yet a different birthday from the other two is 363/365. The probability that none of the three share a birthday, then is 364/365 * 363/365. If we convert these fractions to decimals, we get:
364/365 = .9973
363/365 = .9945
364/365 * 363/365 = .9973 * .9945 = .9918
By adding people to the group we can continue to calculate the probability that none of them share a birthday by using the same approach. For example, suppose we have 7 people selected at random. Then the probability that none of them share a birthday is
364/365 * 363/365 * 362/365 * 361/365 * 360/365 * 359/365
In your program repeatedly prompt the user to enter a positive integer, n. Then calculate and display the probability that no two of n randomly selected people will have the same birthday.
This problem is the same as problem 9, except you should prompt the user to enter a probability value d (a decimal between 0 and 1), and then your program should calculate n, the smallest number of people needed to make the probability less than d. For example, if they enter .993, then your program should calculate 3, since the probability that no two people in a group of three will have the same birthday is .9918, and this is less than .993. As another example, what is n if the user enters .1? You will probably be surprised at how small n is.