Results 1 to 7 of 7
Like Tree1Likes
  • 1 Post By jcharhyde

Thread: Roulette Wheel Quick Help

  1. #1
    jcharhyde is offline Member
    Join Date
    Oct 2012
    Posts
    5
    Rep Power
    0

    Default Roulette Wheel Quick Help

    So, I've fairly far along on a project for school but would love some sort of direction. We haven't used arrays yet so I'd like to avoid using if possible but my question is the following. I've simulating 1000 rolls on the roulette wheel and need to give summary at the end of how many times it landed on red, black, odd and even. the problem is that 1-10 reds are odd numbers and black are even numbers; 11-20 reds are even and black are odd. I really don't want the answer but just a hint as to how I can arrange it to run like that. Obviously, I could write a bunch of if and elses but I would like to be as clever as possible in answering. thanks in advance.

    Maybe I'm not that far along but here is what I'm at so far:

    import java.util.Random;
    import java.util.Scanner;

    public class Roulette
    {
    public static void main(String[] args)
    {
    //Local declarations
    Scanner keyboard = new Scanner(System.in);
    Random generator = new Random();
    int green=0;
    int red=0;
    int black=0;
    int even=0;
    int odd=0;
    int rouletteNum=0;



    System.out.println("Welcome to the Roulette\n");

    for (int roll = 1; roll <=10000; roll++)
    {
    rouletteNum = generator.nextInt(39); //0-38

    if (rouletteNum == 0)
    green++;
    else if (rouletteNum <= 10)
    red++;
    else if (rouletteNum <= 18)
    black++;
    else if (rouletteNum <= 28)
    even++;
    else odd++;
    }

    System.out.println ("Green =" + green);
    System.out.println ("Red =" + red);
    System.out.println ("Black =" + black);
    System.out.println ("Odd =" + odd);
    System.out.println ("Even =" + even);
    }
    }
    Last edited by jcharhyde; 10-29-2012 at 01:44 AM.

  2. #2
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,789
    Rep Power
    7

    Default Re: Roulette Wheel Quick Help

    Simple way to see if a number is odd or even is to mod it by 2. If the result is 0 then it is even. Do that and you only have to work out if it is black or red.

  3. #3
    jcharhyde is offline Member
    Join Date
    Oct 2012
    Posts
    5
    Rep Power
    0

    Default Re: Roulette Wheel Quick Help

    ahh sorry for my ignorance but what do you mean mod it by two? divide the number you mean? sorry thanks for the reply man

  4. #4
    jcharhyde is offline Member
    Join Date
    Oct 2012
    Posts
    5
    Rep Power
    0

    Default Re: Roulette Wheel Quick Help

    also had one more question, this is part of my code:

    else if (num==1||num==3||num==5||num==7||num==9||num==19|| num==21||num==23||num==25||num==27)
    red++;

    is there any way to red++ and odds++ in that same statement? i can one or the other to increase but not at the same time?

  5. #5
    DarrylBurke's Avatar
    DarrylBurke is online now Member
    Join Date
    Sep 2008
    Location
    Madgaon, Goa, India
    Posts
    11,202
    Rep Power
    19

    Default Re: Roulette Wheel Quick Help

    1. You didn't bother to reply to the two responses on your first thread Comparing 3 int value and ordering descendingly . Not the best way to continue to get free help on a forum, that.

    2. Please go through Guide For New Members and BB Code List - Java Programming Forum and edit your posts accordingly.

    db
    If you're forever cleaning cobwebs, it's time to get rid of the spiders.

  6. #6
    jcharhyde is offline Member
    Join Date
    Oct 2012
    Posts
    5
    Rep Power
    0

    Default Re: Roulette Wheel Quick Help

    My apologies to all for the bad form. I did read over the guide for new members when I registered. I find this site and forum resourceful even though I rarely make posts myself. I'll reread the guidelines and ensure I don't make the same mistakes in the future. Thank you and again, sorry for the trouble.
    DarrylBurke likes this.

  7. #7
    Junky's Avatar
    Junky is offline Grand Poobah
    Join Date
    Jan 2011
    Location
    Dystopia
    Posts
    3,789
    Rep Power
    7

    Default Re: Roulette Wheel Quick Help

    Quote Originally Posted by jcharhyde View Post
    ahh sorry for my ignorance but what do you mean mod it by two?
    Do you have a Java text book?
    Does it have an index?
    What do you think will happen if you typed "java mod" into google?

Similar Threads

  1. The Roulette Ready Insurrection
    By wemoAffininna in forum Java Software
    Replies: 0
    Last Post: 01-07-2012, 08:57 AM
  2. How To Make Wheel Look Like It's Moving?
    By kraigballa in forum Java Applets
    Replies: 4
    Last Post: 10-14-2011, 05:50 AM
  3. Roulette game help
    By linc186 in forum New To Java
    Replies: 6
    Last Post: 03-14-2011, 12:47 AM
  4. online ROULETTE CALCULATER
    By dysfunktional in forum Java Applets
    Replies: 2
    Last Post: 05-13-2009, 09:49 AM
  5. Replies: 1
    Last Post: 08-07-2007, 06:59 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •