Help Please: Cool Mathematical Probability

Hi there,
My assignment is to prove that in a group of 30 people, at least 50% have the same birthdays. And in a group of 50 people, 70% have the same birthdays.
I have to use Math.random()*365 for every day of the year and store the values in an array of 30 and 50. I have to check of how many times each array has the same numbers. This program has to run 100,000 times
When you compile and run the program, this is what you should get:
50% 30 people
70% 50 people
This is all I have so far, but I'm stuck and don't know how to check the arrays.
import jpb.*;
public class Project5
public static void main (String []args)
     int[] a = new int[30];
     int[] b = new int[50];
     int ran1 = 0;
     for(int i=0; i<100000; i++)
     for(int cnt=0; cnt<30; cnt++)
          ran1 = (int) Math.random()*365;
          a[cnt]= ran1;

Well, one the one hand it's a simple probability problem. On the other hand, my statistics is REAL weak. Fortunately, my web skills are high, thus turning up:
http://www.studyworksonline.com/cda/content/explorations/0,1035,NAV2-76_SEP949,00.html
Anyway, here's my code. I know it's homework, but it was quick and painless (save for the results which didn't match the original posters, but they match the web site above, so "Works for me!").
Enjoy!
Make sure you cite me as a reference when you turn it in!
import java.util.Arrays;
import java.util.Random;
public class BDay
    Random r;
    public BDay()
        r = new Random();
    public boolean matchingBDays(int numberOfPeople)
        int bdayList[] = new int[numberOfPeople];
        int i;
        boolean result = false;
        for(i = 0; i < numberOfPeople; i++) {
            bdayList[i] = r.nextInt(365);
        Arrays.sort(bdayList);
        for(i = 1; i < numberOfPeople; i++) {
            if (bdayList[i] == bdayList[i - 1]) {
                result = true;
                break;
        return result;
    public float percentMatching(int iterations, int numberOfPeople)
        float successes = 0;
        float result;
        int i;
        for(i = 0; i < iterations; i++) {
            if (matchingBDays(numberOfPeople)) {
                successes++;
        result = successes/(float)iterations;
        return result * 100;
    public static void main(String args[])
        BDay b = new BDay();
        System.out.println("100,000 iterations with 25 people:" +
                           b.percentMatching(100000, 25));
        System.out.println("100,000 iterations with 60 people:" +
                           b.percentMatching(100000, 60));

Similar Messages

  • I am unable to connect my iPhone5 to macbook Pro running on Version 10.6.8. Help please?

    I am unable to connect my iPhone5 to macbook Pro running on Version 10.6.8. Help please?

    You probably need to upgrade your Mac software to 10.8.2 to handle ios6.

  • Cool sense any help please

    i have a hp dvd7 c600us, and i was so fast and cool to play and work, but i started to see a blue screen windows error, i read it, i posted the error and i founded alot user with same error and it was because coolsense stoped to work, i uninstaled and try to install again, but i couldn´t doit..
    hpthermalassistant.exe is gonne... how can i solve this... any help please
    i orderded the recovery cd data cause my restore in hdd cames corrupted, i reinstaled like factory but after update my coolsense has gone.. anny help
    using windows 7
    Andrew Murdock

    Hi,
    Please try uninstalling the HP Support Assistant program on your Notebook and installing  an older version like this one: 
    (Version: 6.1.12.1). 
    http://h10025.www1.hp.com/ewfrf/wc/softwareDownloa​dIndex?softwareitem=ob-99047-1&cc=us&dlc=en&lc=en&​...
    If this version does not work, you can try try re-installing the HP Support Assistant program (HPSA) from the Recovery Manager software.  Please find the deails here: 
    Using Recovery Manager to Restore Software and Drivers (Windows 7):
    http://h10025.www1.hp.com/ewfrf/wc/document?docnam​e=c01868333&cc=us&dlc=en&lc=en&jumpid=reg_r1002_us​...
    If doing the above steps do not work, please go ahead and uninstall HP Software Framework and HP CoolSense Technology programs from your Notebook and re-install them from the following links
    HP Software Framework: http://h10025.www1.hp.com/ewfrf/wc/softwareDownloa​dIndex?softwareitem=ob-106977-1&cc=us&dlc=en&lc=en​...=
    HP CoolSense Technology: http://h10025.www1.hp.com/ewfrf/wc/softwareDownloa​dIndex?softwareitem=ob-113328-1&cc=us&dlc=en&lc=en​...=
    I am waiting to hear back from you.
    !------------------- Please click the KUDOS star on the left to say 'Thanks'. Please mark 'Accept as Solution' if it answers/solves your problem. Thank you-----------------------------------------------​------------------!
    I am an HP Employee. 

  • 'Error loading plugin: Plugin file not found' message on ONLY 5 sites, but all others OK.  Help, please!

    Hi Again!
    I posted this problem here before, but since I really need to access the sites that receive this error message in less than a month, I had to re-post; hopefully someone who didn't see it before will see it & have a solution for me.
    Here are the details:  I'm running windows 8.1 & I use Firefox 33.1.1, Pale Moon 25.1.0 or Opera 26.0 as my browsers, (I have IE installed & up-to-date, but I never use it).  I followed the 10-point checklist on Adobe & everything was done, except for "uncheck Hardware Acceleration" in Flash 'Settings'; I tried to uncheck it on this site, where it's indicated, as well as in my 4 browsers when I'm doing something that uses Flash, but no matter how hard I try, I can't 'uncheck' the check mark in that tiny box!  Since this error problem only affects 5 web sites, & I can watch streaming media on all other sites, I don't think it's an issue. 
    Here's how this problem began:  I was watching a live, streaming nest-cam on 5/09/14 around 11:00AM, (yes, I DO know the exact time & date, because it happened so suddenly while I was watching this website that I'd been watching since the end of February, 2014), when my screen went black.  I thought it was probably an Adobe Crash, but when the usual Crash Report window didn't show up, I just closed Firefox & reopened it, expecting to resume watching the nest-cam.  When I went back to the site, I got the black screen with the "Error loading plugin: Plugin file not found" message.  The chat portion on the site still works, though. I know there are other sites with this nest-cam feed, so I started trying them, but it took several tries for me to find one that didn't get the error message! I posted this problem on "Windows BBS" forum, & someone else posted that the same thing happened to them AND on the same sites!  They didn't have a solution, either.  I cleared my cache, rebooted my PC & even did a System Restore, but whatever happened in that brief second made using ONLY 5 sites impossible.  Here are the sites that receive the error message:
    http://pixcontroller.com/eagles, (but I CAN go to http://pixcontroller.com, but there isn't any streaming media)
    http://cbslocal.com/eagles
    http://westmorelandconservancy.org/BlueBirdwebcam-1.htm
    http://wildearth.tv/cam/pittsburgh-bald-eagles, (I get the error message on ALL cams on this site)
    http://aviary.org/BE-NestCam1 (I get the error message on ALL cams on this site)
    Now if any videos from the 5 websites above are uploaded to YouTube, I can watch them perfectly...no error message if I watch the videos elsewhere.  Luckily, I found Ustream, & they have most of the nest cams I watch, but I need to fix this issue, because it's nearing nesting time!  I'm an amateur nest-watcher & it's vital that I have access to these 5 sites, so if anyone knows how to fix this, PLEASE tell me!
    Thanks for taking the time to read my post.
    All suggestions/solutions are gratefully accepted.
    Thanks in advance for your help!
    DogPal 

    File Not Found Error in Welcome Screen
    07-Nov-2013 10:25
    Tags: #dreamweaver_cs6_update
    Help please!
    Live preview also not working.
    I have exactly the exact problem described below but do not have a folder with the same name as the volume created under the volume. Please can someone help - I've tried everything. This problem only happened when I upgraded to Dreaweaver CC!
    "On launching Dreamweaver on your Macintosh if your Welcome Screen is not loading and if you see a "File not found" error, please check if you have a folder with the same name as your volume created under the volume. For more info on this please go through the attached pdf document. Other dialogs/panels in dreamweaver that will be blank due to this issue are Jquery Swatches panel, Adobe Edge Webfonts tab in Manage Fonts dialog,W3c Error Info dialog, Externalise Javascript dialog and svn revert dialog. After following the changes mentioned in the attached document please check all the affected dialogs/panels to confirm everything is working as expected."
    Thanks,
    Martin Bond
    [personal information removed by moderator]

  • HT3702 I'm trying to update a game and its telling me I need to view my billing.i check my billing and it isn't giving me a none option. It's forcing me to put a credit card in, in order to update a game. Help please:(

    I'm trying to update a game and its telling me I need to view my billing.i check my billing and it isn't giving me a none option. It's forcing me to put a credit card in, in order to update a game. Help please:(

    Well, that is probably becasue you owe a debt or something similar.
    Check with
    iTunes Store Support
    http://www.apple.com/emea/support/itunes/contact.html

  • My iPod touch is not synching to iTunes. Meaning it's not showing up in my devices when I go to them through the 'Edit' button at the top of the iTunes window. Help please!!!

    My iPod isn't synching. It's not even showing up in the Devices. I know it's ocnnected becasue it's charging. Help please! Probably an epic noob fail xD

    Try here:
    iPhone, iPad, or iPod touch: Device not recognized in iTunes for Windows
    or
    iPhone, iPad, iPod touch: Device not recognized in iTunes for Mac OS X

  • Troubleshooting: Help please. Creating a PDF file from a Photoshop-designed project

    I wanted to add personal design elements to my resume so I decided to use Photoshop to add in a logo and a footer. The problem is, when I converted the 3 Photoshop .psd files (3 pages) to .pdf files, the combined file came out to be very big in size. The biggest was 2.88 MB and the smallest that I got it to be without compromising the quality of the text and images was 1.48 MB.
    What did I do wrong?
    I've seen other .pdf files with more images and more color and definitely more pages and text which were only 300KB in size. How can I make my final .pdf file size small but still retain the quality of the original design from Photoshop?
    I've tried merging the layers before saving. I've tried turning the files into .gif files before making the pdf. Into jpegs before making the pdf. Changing the canvas and image sizes in Photoshop into super small which made the final pdf file unreadable and super blurry. I'm at my wit's end.
    Details:
    .psd image size 8.5 by 11 inches (normal resume size)
    colors - black, gray, light blue and light yellow
    Images are very minimal, 4 lines total and around 5 circles at the header of the first page and footer of the 3rd page.
    Help please!
    X-cross-post: Acrobat Forum-X

    This is so sad. I read your comments and I said, "Huh?" Haha!
    I tried the indexed color option and it did make the final file smaller. Around 600KB. But there's probably another way to make it even smaller like the gazillion-paged pdf file that I mentioned that was only about 300KB.
    And by saying a layout program, does that mean like Adobe InDesign? Does that mean that I should just make my graphics in Photoshop and then import using another program and finish the file there?
    What other layout programs can I use?
    Thank you so much!

  • Iphone 4 won't turn on! Help Please!

    my iphone4 suddenly turned off, now  it won't turn on. connected it to itunes on laptop. tried to restore it but still stuck with "Waiting for iPhone" and an apple logo with a blank progress bar. Help please!

    i just finished charging my phone then i disconnected it from the charger and then right after that moments after it just crashed and screen went black. so probably you're right, it might be the battery of the software may have crashed.

  • I buy extension from adobe online, i installed it correctly but then the extension menu was greyed out and i can't click it. Some help please.

    I buy extension from adobe online, i installed it correctly but then the extension menu was greyed out and i can't click it. Some help please.

    hello ptbruce, you probably only selected to open (not save) the video which will download it into windows temporary folder where it gets deleted again after it has been used. <br>you could try to right-click the entry in the firefox download manager and copy the link of the source file and try if you can download it through this url again. otherwise you'll have to contact the vendor of the video to find a solution...

  • Itunes converrts videos for ipod but then thay have no SOUND!!! Help please

    Itunes converrts videos for ipod but then thay have no SOUND!!! Help please
    Just bought it a couple of days ago, and its doing this!!! why doed the videos now both on my ipod and itunes not have sound?

    Your source video file is probably muxed.
    Neither QT Pro or iTunes has the ability to successfully encode a muxed video file with audio. You'll end up with video and no audio.
    You'll need to use some other third-party software to do the conversion. There's a handful of software available. Just search the forums and you'll find many titles mentioned.
    Try MPEG Streamclip.

  • Hello.I wanted to upgrade my iPad 1 to iOS 5.1 Over the Air.I was running iOS 5.0.1.It said it had an error connecting to server.It is already 5 hours i cant install this update.I also have an iPhone 4 with iOS 5.0.1 with the same issues.Help please!

    Hello.I wanted to upgrade my iPad 1 to iOS 5.1 Over the Air.I was running iOS 5.0.1.It said it had an error connecting to server.It is already 5 hours i cant install this update.I also have an iPhone 4 with iOS 5.0.1 with the same issues.Help please!

    You're probably running into the servers simply being swamped. Thousands of people are all going for the software update at the same time. Give it a try again and if that doesn't work, then try plugging it into your computer and trying it that way.
    I didn't get a notion of the size, it doesn't seem to be as big as the 700 meg 5.0 update, but it did take me 20+ minutes to download via cable internet so it's a large file. That in and of itself takes a while.
    If you're trying to download it directly to your iPhone, you'll need to be on wifi since I'm sure it's well over the 20 meg file size limit for 3G.

  • Blast speed is currently 2 Mbps/9 Mbps on the Comcast Speed Test. Help please!

    I've had the Blast service for quite some time, and have noticed painfully slow internet browsing for the last couple of months. I mean...pull-my-hair-out-slow.  I just did a Comcast speed test and the results were 2.31 Mpbs and 9.01 Mpbs. Um....that would explain things. But not really... as I'd love to see the speeds I'm supposed to have. Even double digits would be nice! I'm trying to run ShaperProbe but I get the error "Servers are busy. Try again later." I've tried a few times. I'll post the results if I can get the scan to work. Power level is 45-46 dBmV and SNR 35-37 Modem: ARRIS Motorola SurfBoard SB6141 DOCSIS 3.0Logs of June 2015 (the most recent, and the logs before that are January): Jun 22 2015 07:07:243-CriticalT05.0SYNC Timing Synchronization failure - Loss of Sync;CM-MAC=b8:16:19:fa:b8:0c;CMTS-MAC=00:1d:70:af:fd:a0;CM-QOS=1.1;CM-VER=3.0;Jun 18 2015 08:04:503-CriticalR02.0No Ranging Response received - T3 time-out;CM-MAC=b8:16:19:fa:b8:0c;CMTS-MAC=00:1d:70:af:fd:a0;CM-QOS=1.1;CM-VER=3.0;Jun 18 2015 07:08:273-CriticalT05.0SYNC Timing Synchronization failure - Loss of Sync;CM-MAC=b8:16:19:fa:b8:0c;CMTS-MAC=00:1d:70:af:fd:a0;CM-QOS=1.1;CM-VER=3.0;Jun 17 2015 23:08:553-CriticalR02.0No Ranging Response received - T3 time-out;CM-MAC=b8:16:19:fa:b8:0c;CMTS-MAC=00:1d:70:af:fd:a0;CM-QOS=1.1;CM-VER=3.0;Jun 16 2015 02:43:065-WarningZ00.0MIMO Event MIMO: Stored MIMO=-1 post cfg file MIMO=-1;CM-MAC=b8:16:19:fa:b8:0c;CMTS-MAC=00:1d:70:af:fd:a0;CM-QOS=1.1;CM-VER=3.0; I would sure appreciate any ideas. I have not contacted tech support yet, although that may be faster??  We'll see.  Thanks in advance for any help!  

    ShaperProbe has not been usable for some time, unfortunately. Check to see if Comcast is reporting an outage for your area by logging in to https://customer.xfinity.com/Secure/MyServices/ or by checking the voice response system at 1-800-Comcast.
    If no outage is reported, see Connection Troubleshooting Tips. If you want to troubleshoot this yourself and still need help, please provide Information Requested for Connection-Related Posts.
    If you are using Wifi it's best to switch to an Ethernet connection if possible while measuring speed and checking the reliability of your connection to Comcast.
    If you'd rather have them do the troubleshooting call them at the phone number on your bill or 1-800-Comcast and have them send a tech out to identify the cause and correct it.
    If the tech finds bad coax, splitters, amplifiers, or connections in your home (even if Comcast originally supplied them) you'll probably have to pay for the visit unless you have their Service Protection Plan (http://www.xfinity.com/spp/, about $5/mo). If the trouble is due to a faulty Comcast modem, eMTA, gateway device, or anything outside your home, you shouldn't be charged.

  • About Ready To Throw Printer In The Trash!! Cartridge Issues!! Help Please:)

    I have an all in one 3135 Photosmart. I can scan fine, the issues are related to printing. I have the blinking top 2 lights only, the check paper and check cartridge. I went thru all the online troubleshooting steps. I do get an error on my computer that says carriage jam but the carriage moves freely and there is no paper inside. 
    Also... I feel like a real idiot now... why do I have FOUR print cartridges? There are two on the carriage itself and two on the right side of the printer. I used to be a systems manager but I've had a stroke and now things like this are causing my mind to just blank. 
    I tried to follow the steps to remove the two print cartridges on the carriage but I can only unseat them, not remove them at all. 
    Somebody help please... I am probably doing something incredibly stupid. Thanks!!! 

    The cartridges are only accessible for replacement on the right side of the printer.  It is possible an extra set of cartridges have been installed in the right side slot while there were still cartridges in the carriage.  Your printer only holds two cartridges, if there are four installed I would suggest you remove the two in the right side, then turn on the printer, open the carriage access door and allow the carriage to move to the right to change the cartridges in the printer.  At this point both sets of cartridges may be damaged, as they may have sat from some time outside the protective caps.  You may need to run a few cleaning cycles after the cartridges are reseated properly.
    The video here may help resolve the issue.
    Bob Headrick,  HP Expert
    I am not an employee of HP, I am a volunteer posting here on my own time.
    If your problem is solved please click the "Accept as Solution" button ------------V
    If my answer was helpful please click the "Thumbs Up" to say "Thank You"--V

  • After I loaded Mac OS lion, it won't let me install my Sierra Wireless telstra. It keeps telling me to install it even though i already have. help please?

    After I loaded Mac OS lion, it won't let me install my Sierra Wireless telstra. It keeps telling me to install it even though i already have. help please?

    Check for new 64 bit software for the modem, other wise you I'll probably have to boot your Mac in 32 bit mode first.. And then every time you want to go online.
    I have the Sierra wireless 306 and have their 64 bit lion software installed. Works well.
    Best.

  • "We could not complete your iTunes store request. The connection was reset". Help please!

    Help PLEASE!
    Let me explain my situation:
    - iTunes store has been working fine on all computers for the past few years.
    - Modem gets struck by lightning last Mon.
    - Get a new Netgear modem yesterday.
    - Internet all working fine. Can browse, download etc. in browser (Mac App store, and iDevices App Stores all working fine, too)
    - Cannot connect to iTunes store. Get error "We could not complete your iTunes Store request. The network connection was reset".
    - I Get the same error on 2 MacBooks, but i can browse the store on my 2 Win7 PC's.
    - I managed to connect and browse on my one MacBook using a 3G modem, but still no luck with the ADSL connection.
    - I have tried connecting via wired (ethernet) connection to the modem. Still no luck.
    - I have had this problem on iTunes 10.2, 10.4, 10.5 Beta, and 10.5.
    Does anyone have any idea what is going on here? Any help and advice would be greatly appreciated!
    Thanks!
    George.
    Modem Model no.: DGN 2200

    with everyone downloading the update, the servers are probably bogged down with requests, probably just wait it out and it will start to download and get you back up and runnin
    dante

Maybe you are looking for

  • Print multiple copies in Crystal Report

    Hi All, I have created layouts with Crystal 2008 . I need to print first copy as original , second as duplicate and the third as triplicate . I know it is possible using PLD but i need it in CR. Is there any work-around for this problem ? I am using

  • READ THIS IF YOU'RE HAVING TROUBLE SYNCING SONGS/VIDEOS TO YOUR iPod

    Sometimes the album artwork, even if it was supplied from the iTunes store, corrupts the file. Just right click the song or video in your library, click "Get Info," and then click the "Artwork" tab. Click on the artwork and delete it, then try sync i

  • IPhone and backing up to Time Capsule

    Hi all, New to this forum so please excuse if this is a stupid question, but my Time Capsule arrived today, have the wireless network all running nicely and various computers backing up to it, my next question is does anyone have an iphone backing up

  • Imac g3 cd drive reconized but not booting

    Hi i just got a imac G3 tray loadin and i tried installing a game on it. It saw the cd drive is reconized but the disc is not appering on the desktop. the same thing happens when i try to install a operating system It will not boot the disc. But on s

  • Using an Aiport Express in a hotel with no computer?

    Quick question about the Airport Express. I have one and use it to extend my Airport Extreme network at home, but I'll be travelling soon and staying in a hotel with ethernet but no Wi-Fi. I'll have my iPhone with me, but not my Macbook. Question is,