Please help, i am having trouble figuring it out- two sided dice

In the game of Craps, a "Pass Line" bet proceeds as follows. Using two six-sided dice, the first roll of the dice in a craps round is called the "Come Out Roll." The bet immediately wins when the come out roll is 7 or 11, and loses when the come out roll is 2, 3, or 12. If 4, 5, 6, 8, 9, or 10 is rolled on the come out roll, that number becomes "the point." The player keeps rolling the dice until either 7 or the point is rolled. If the point is rolled first, then the player wins the bet. If the player rolls a 7 first, then the player loses.
Write a program that plays the game of Craps using the rules stated above so that it simulates a game without human input. Instead of asking for a wager, the program should just calculate if the player would win or lose. The program should simulate rolling the two dice and calculate the sum. Add a loop so that the program plays 10,000 games. Add counters that count how many times the player wins, and how many times the player loses. At the end of the 10,000 games, compute the probability of winning, i.e. Wins / (Wins + Losses) and output this value. Over the long run, who is going to win the most games of Craps, you or the house?
please help me in this project
public class Kharel_Ch3_2 {
public static int NUM_GAMES = 10000;
public static void main(String[] args) {
int numWins = 0;
int numLosses = 0;
int x;
int y;
x = (int)(Math.random()*6) + 1;
y = (int)(Math.random()*6) + 1;
System.out.println("The roll of first Dice is " + x);
System.out.println("The roll of Second Dice is " + y);
int roll = (x + y);
System.out.println("The sum of two dice is " + (roll));
int point = (4 & 5 & 6 & 8 & 9 & 10);
for (int i = 1; i<=10000; i++)
if (roll == 7 || roll == 11)
System.out.println("You win!");
numWins = numWins +1;
else if (roll==2 || roll==3 || roll==12)
System.out.println("You Lose!");
numLosses = numLosses + 1;
else
System.out.println("Roll Dice again!!!");
x = (int)(Math.random()*6) + 1;
y = (int)(Math.random()*6) + 1;
roll = (x + y);
if (roll == point);
while (roll !=7 || roll !=point)
x=(int)(Math.random()*6);
y=(int)(Math.random()*6);
roll = (x + y);
int sum = roll;
if (roll== point)
numWins = numWins+1;
else numLosses=numLosses+1;
// Output probability of winning
System.out.println("In the simulation, we won " + numWins +
" times and lost " + numLosses + " times, ");
System.out.println("for a probability of " +
(double)(numWins)/(double)(numWins + numLosses));
}

{ public static int NUM_GAMES = 10000;
public static void main(String[] args) {
int numWins = 0;
int numLosses = 0;
int x;
int y;
x = (int)(Math.random()*6) + 1;
y = (int)(Math.random()*6) + 1;
System.out.println("The roll of first Dice is " + x);
System.out.println("The roll of Second Dice is " + y);
int roll = (x + y);
System.out.println("The sum of two dice is " + (roll));
int point = (4 & 5 & 6 & 8 & 9 & 10);
for (int i = 1; i<=10000; i++)
if (roll == 7 || roll == 11)
System.out.println("You win!");
numWins = numWins +1;
else if (roll==2 || roll==3 || roll==12)
System.out.println("You Lose!");
numLosses = numLosses + 1;
else
System.out.println("Roll Dice again!!!");
x = (int)(Math.random()*6) + 1;
y = (int)(Math.random()*6) + 1;
roll = (x + y);
if (roll == point);
while (roll !=7 || roll !=point)
x=(int)(Math.random()*6);
y=(int)(Math.random()*6);
roll = (x + y);
int sum = roll;
if (roll== point)
numWins = numWins+1;
else numLosses=numLosses+1;
// Output probability of winning
System.out.println("In the simulation, we won " + numWins +
" times and lost " + numLosses + " times, ");
System.out.println("for a probability of " +
(double)(numWins)/(double)(numWins + numLosses));
}}

Similar Messages

  • Having trouble figuring out how to save the original photo after I've cropped it - i.e. I want to create a headshot of my husband from a photo of the two of us, but I also want to keep the original. Seems very basic, but can't seem to figure it out. Any h

    Having trouble figuring out how to save the original photo after I've cropped it - i.e. I want to create a headshot of my husband from a photo of the two of us, but I also want to keep the original. Seems very basic, but can't seem to figure it out. Any help would be great!

    Use File >> Save As
    Choose a different file name so as not to overwrite the original and don't save any changes when closing the original.

  • My old phone broke and I am having trouble figuring out how to restore my contacts on my "new" phone (LG ENV2 Black)...

    My old phone broke and I am having trouble figuring out how to restore my contacts on my "new" phone (LG ENV2 Black).  Apparently the phone is so old that I am unable to install Backup Assistant on it, which sucks.  I have all my old contacts saved on my computer as a CSV and also another copy on a micro SD as VCF.  I have tried moving the CSV from my computer to my ENV2 via both Bluetooth and USB cable, but had no luck with either of those.  I also tried to pop the micro SD into the ENV2, and although I can load all my old pictures/videos/etc. from the micro SD, I do not seem to be able to restore the contacts from card.  I know there has to be some way to manually transfer these files; the contacts are still on my old phone as well; but I was unable to use the transfer wizard for that because my old phonedoesn't seem to be supported by that (Pantech Jester 2)

    Google a program called bitpim, that might do what you want.  Never used it but it's been talked about on the forums.  Other than that you might have to input them manually.  Mary

  • Help I am having trouble updating Ipod's

    Help I am having trouble updating our Ipod's & Iphone.  I have followed the troubleshooting on Itunes error page, but still not working.
    I don't have an error number just this message -  "There was a problem downloading the software for the iphone "A's iphone" the network connection was reset.
    Itunes downloads the update, but at the end gives the error message. I have the latest itunes installed and Microsoft is up to date, nothing else connected via  usb. This happens with our ipods as well. Thankyou

    On your windows computer...
    Temporarily disable your firewall and antivirus software and try again...
    See here for Connection Issues
    http://support.apple.com/kb/TS1379
    From Here
    http://www.apple.com/support/itunes/troubleshooting/

  • Having trouble figuring out how to forward text messages.  Can someone tell me how to do that?  Where the forward button.  You used to be able to hit forward and put radio button on all the messages.  The screen looks blank to me.

    In the new iOS7, Having trouble figuring out how to forward text messages.  Can someone tell me how to do that?  Where the forward button.  You used to be able to hit forward and put radio button on all the messages.  The screen looks blank to me.

    In the new iOS7, Having trouble figuring out how to forward text messages.  Can someone tell me how to do that?  Where the forward button.  You used to be able to hit forward and put radio button on all the messages.  The screen looks blank to me.

  • How do you find out the contacts that were updated via Facebook and twitter in the settings without having to figure it out manually?

    How do you find out the contacts that were updated via Facebook and twitter in the settings without having to figure it out manually?

    There is no such list of what is downloaded to each phone except in the backup. So if you have a recent backup of each phone you should be able to find an app that reads the backup files and would tell you what list is saved of the content on each phone.

  • HELP PLEASE! I am having trouble charging my iPod Mini 4GB

    I am having trouble charging my iPod Mini 4GB. I used it for approx 30 minutes until it died, and it will not charge. I have tried charging it through the USB port and also the wall charger - but nothing comes on the screen to say it is in the process of charging and it will not switch on. The trouble shooting section of the manual says there should be a thunder flash icon?? Any ideas please?
    Could it be the internal battery at fault? Shall I buy a new one from Maplin?

    my iPod mini is doing the same thing. i'll charge it all night through a wall charger (all connections seem to be ok, the charging icon appears on the screen). but i'll take it off and turn it on for not even 5 minutes and it wil turn off! i charged it for about a week once and i took it off the charger for again, 5 minutes, and the thing turned off on me. i've sent my iPod in for service before because it was frozen, but this battery issue hasn't happened to me until recently.
    if i send my iPod in for a replacement, what kind will i get back? one of my friends said that if i sent it back in, i would get a 2GB nano. thats not enough!! how do i get more?

  • Please help I am having big trouble!!

    Hey,
    I really need help. I have never had a problem with my I-pod mini but today was the first day I tried downloading a burnt CD song on it(my mini i-pod). It would work and play on my comp. and it looked as if there weren't any problems downloading it from my comp. to ipod, but when i tried to find it there were no traces of it anywhere on my i-pod!!!
    please help thx
    from,
    a worried costemer

    Hi Heather and welcome to Disussions.
    First Reset your iPod and then download the song to your iPod again. Check it in iTunes by playing it again (Iknow you already did it once) and then see if you can find it.
    Hope thi shelps, post back with questions

  • PLEASE HELP ME! WIFi troubles and i am desperate

    2-3 days ago my phone was working fine, i dont use a data plan i always use wifi, my house has wifi, whereever i go i use wifi. I left my phone charging when i got back it started acting strange, i could no longer receive bbm messages, i tried msn and it says 'no data service available'.....the status of my wifi connection is on yellow, but with all this the name of the network is at the top of my screen plus i can use my opera mini to browse and also the default blackberry browser, but nothing else works with the wifi.
    I have used desktp manager to erase and reinstall, i have upgraded, i have restarted, i have tried tweaking settings, options that were there before are gone for example, ota upgrade..... i have checked module its getting signal, i am lost, i am desperate and i am getting really sad because i really really need this phone to work, please help me please anyone.....someone.....
    it gets worse by the minute because now its saying ip no longer valid.....i dont know whatelse to do or say ask me anything about the phone......

    I "suspect" that since your Data Plan is on another carrier, and you have roaming turned off, the network is not seeing the device has having a BIS plan. That is my guess.
    Further, the fact that it worked before doesn't really matter, since there are several factors which come into play, such as ALL of the BIS data services are enabled by Service Books pushed to your device.For example, BBMessenger is enabled by Service Book, much as email accounts, etc. You could have had the service book required for quite a while since you've been travelling. As much as rebooting the device, and the device seeing it is not connected to a BIS data plan, could remove that service book, since there is no BIS plan.
    Even further, your browser, set to HotSpot browser should indeed work with WiFi only and no BIS service... for example, I have next to me a Bold 9000 with NO SIM in the device, at all. I can use the browser to go to most any site, works great, using only WiFi.
    From your 8320 user guide
    Wi-Fi network
    Green:  Your device is using UMA or is accessing BlackBerry services (for example, email service) over a Wi-Fi® connection.
    Yellow: Your connection to the Wi-Fi network is turned on, but your device is not using UMA or does not have access to BlackBerry services
    over a Wi-Fi connection.
    Red:  Your connection to the Wi-Fi network is turned off.
    1. If any post helps you please click the below the post(s) that helped you.
    2. Please resolve your thread by marking the post "Solution?" which solved it for you!
    3. Install free BlackBerry Protect today for backups of contacts and data.
    4. Guide to Unlocking your BlackBerry & Unlock Codes
    Join our BBM Channels (Beta)
    BlackBerry Support Forums Channel
    PIN: C0001B7B4   Display/Scan Bar Code
    Knowledge Base Updates
    PIN: C0005A9AA   Display/Scan Bar Code

  • PLEASE HELP droid 2 global trouble syncing goggle calendar

    Just got the droid 2 global, went to enter an appoinment in my calendar for the first time , message comes up saying "must sync with calendar before entering an event".. ok so I never had to do this with my Droid x. but we went on goggle.com on a PC followed instructions in syncing calendar and it didnt work, on the phone I looked in the accounts tab them clicked on gmail and there were only two options one was SYNC CONTACTS, the other SYNC GMAIL,  in my X I have three options the same two and the third is SYNC CALENDAR.  so How so we get this to work???? cant even use another caledar app off market, it keeps giving same message. PLEASE SOMEONE HELP!!!!

    Holly_SwordLily wrote:
    on my droid 2 the one that came out before yours i added a gmail account i didnt need and then the option came up for me to sync my calendar with the gmail account i wanted, then i deleted the gmail account i didnt need. i know confusing for me to but this worked. good luck.
    for those of you this worked for it was my husband who figured it out. it helps to have a computer expert in the house ^^ most answers i have been able to find via google but sometimes you got to go to the pros

  • PLEASE HELP NEW IPOD IN TROUBLE

    i had no trouble uploading songs or videos, but all of a sudden my music stopped playing and i couldn't do anything to fix this. i didn't drop the ipod or anything, the files show up, games work,everthyings there but the timer on the song stands still and no song will play. this ipod was only 4 days old? whats going on please help! it'n not paused either, the osngs just don't play!

    Yehlena,
    I am glad we could help, but your not done yet;) I think you should award King the solved points for informing you about the restoring feature.
    One of the responsibilities of the original poster (sometimes referred to as OP) is to award points to the "solver" as well as the most helpful. The reason being, not only does it show how the problem was fixed, but it 5-10 points (depending on helpful or solved) to those who helped the most. I like to think of it as paying them back with Monopoly money. It doesn't count anywhere else, but here. The reason for these points (I believe) is to show a rough estimate someone has been helpful as well as reduce the number of slipshod responses (the idea that someone will put the extra effort to try solve/help the problem). It has become proper etiquette when posting in the forums to issue these post (my opinion). I am not an Apple host/moderator, nor do I have any authority/say in this forum. I am "just another brick in the wall". It's up to you; I just thought it was something worth mentioning.
    Thanks,
    Jon
    Mac Mini 1.42Ghz, iPod (All), Airport (Graphite & Express), G4 1.33Ghz iBook, G4 iMac 1Ghz, G3 500Mhz, iBook iMac 233Mhz, eMate, Power Mac 5400 LC, PowerBook 540c, Macintosh 128K, Apple //e, Apple //, and some more...  Mac OS X (10.4.5) Moto Razr, iLife '06, SmartDisk 160Gb, Apple BT Mouse, Sight..

  • Please help!!! trouble using UI Roadmap on a PDK application for EP 7.0

    Hello all,
    I'm developing a PDK application in wich I would like to use a roadmap UI control. Is this possible to do?. At this moment i'm trying to do this by using
    the source code generated by webdympro, this works on a EP 6.0 server but, it doesnt work on a EP 7.0 server. is this version component (EP 7.0) needs some kind
    of adjustment or configuration to use the roadmap UI Control within a PDK application or It can be done in another way?
    Please Help!!
    Regards,
    Mariana

    Hi,
    I have never worked with the examples but I can tell you how to solve your problem in situation 1. The portal user you use to preview the iView does not have sufficient permissions for the security zone to which the iView belongs.
    To set the permissions follow the instructions below:
    1) Log into portal with system administration rights
    2) Navigate to => "System Administration" => "Permissions" => "Portal Permissions"
    3) Open folder "SecurityZones/com.sap/UndefinedSecurityArea/no_safety/Example12/components"
    4) Right-click object "ExampleLayer" and choose "Open Permissions" from context menu
    5) Set permissions for your user
    6) Save changes with click on "Save" button
    Best regards,
    Martin

  • Please HELP!!! Trouble w/ videos!

    I purchased some music videos and TV shows from iTunes Music Store. At first no problem. Played great.
    I connected my iPod to a computer that had iTunes 4 (not video capable).
    Ever since - I have not been able to view my music videos or TV shows with my iPod or iTunes.
    I tried connecting my iPod to another computer that did have a more updated version of iTunes (iTunes 6), but couldn't find how I would do anything to remedy this situation.
    In iTunes the info summary tells me that they are MPEG 4 video files, yet they still don't not play as a video. I am able to hear but there is no video.
    Also these titles don't show in the 'Videos' menu in my iPod. They are listed as 'Songs'. When i first purchased them they were listed in the 'Videos' menu, but ever since I connected my iPod to the computer with iTunes 4 they are not.
    I have already made sure the Video Setting / TV Out is set to "OFF" or "ASK"...still doesn't work.
    Any ideas??? Please HELP!!!!!

    Ahhh... No wonder the confusion Nadav.
    I bought the card 2nd hand from a guy on ebay with perfect feedback who owned it since late December, then traded up to a new Power Mac from the G5 he had it in. For it to work on the G5 he removed the tape that came on it from mac-geniuses. I then had to re-tape it for it to boot.
    I trust that it worked for the previous owner - it does work when I run Tiger, just not on Leopard!?!

  • PLEASE HELP, itunes and ipod trouble!

    i have upgraded to the new itunes. uploaded new music into itunes, made space to put these songs on my ipod old 15GB model. when i plugged in the ipod into my imac it made the changes i made to deselecting songs but will not upload the new songs i have put into itunes...i tried restoring my ipod and it says that there is an unknown error...what do i do?!?!?! ahhhhh please help
    thanks
    -tm

    i would like to also add that i tried making changes to teh setting of my pod like syncing all songs in the music tab in ipod settingsand its says that the ipod cannot be found!?!?! pleaaaaaaaaaaseeeeee helpppp
    -tm

  • HT1349 I have been using an app ( cheat with words qith friends) that I have been using for a long time.  One day it just won't read the screen shot.  It still works on my iPhone   Please help!!  The trouble is on my iPad. Thank you!!I

    I have been using an app cheat with friends with my iPad for a long time. One day it just stopped reading the screen shot.  I have tried deleting a few times and starting over. It works on my iPhone perfectly fine. Please help !!!!!!!  Thank you

    @Colin Robinson
    Thanks, I did it hundreds of time!!!
    Anyway here's what I did:
    I'd wrote an email to Apple America, even if I'd purchased the item in Europe and the US support usually should not be involved in any European case.
    They wrote me back that a European office will have call me in 48 hours.
    After a couple of days I've received a call and a new iPod is coming from US...
    Don't ask me if I can find any kind of logic behind it, but at least I can state that the US support has been decisive.
    Thanks to everybody.

Maybe you are looking for

  • Why can't I open the apple store on my iPhone

    First let me say this is a phone I got sent from Apple. The issue I have is when using my extension cable once fully charged my phone says charging is not supported with this accessory. Next issue I have is I can't log into the App Store on my phone.

  • Error message cannot load content?

    Apple TV dropping out after 3 minutes repeatedly.  Internet signal strong and working, Telus tech verified. Followed general troubleshooting of steps, all settings appear correct.  Several months no problems, now dropping out.  Not sure what to try n

  • How do I set up streaming video using iWeb

    Where can I get a straight forward guide to setting up a streaming video to my web site. I use iWeb to design and publish my web sites to mac.com. And I have a personal domain that I host on mac.com. I want to set up a wireless web cam because locati

  • Not seeing block diagram when opening vi

    Hi, This is trivial but frustrating. When I open a vi I see the front panel, and then have to press ctrl E to see the block diagram. Can anyone tell me if there a way of opening the vi and seeing both the front panel and block diagram immediately ? M

  • Recording sounds using the built-in microphone.

    I would like to record some household sounds and save them to iTunes. How can I do this? I have been able to download some sounds from commercial sites, but need different ones.