Results 1 to 14 of 14
  1. #1
    manowar689 is offline Member
    Join Date
    Jun 2010
    Posts
    16
    Rep Power
    0

    Default making a program emulate roulette HELP!!

    ok heres the thing im trying to make a pogram to emulate a roulette table for practice but for some reason a certain question keeps looping when it shouldnt its this question "please input you bet now" now i have it set to loop till the bet is less then the stake therefore not betting with money you dont have the loop wont work tho it makes me enter more the the stake for some reason and the this if statement "if (num == Q2)" gets opened even if num being the number at random and Q2 being the users input arent the same any help would be appreicated :):):) ps i know there isnt a loop for if they lose but i havent got that far lol

    Java Code:
    //--------------------------------------------roulette table----------------
    class roulette{
    
    	public static void main (String[] args){
    	int num;
    	int col;
    	int stake;
    	int Q2;
    	int bet;
    	int Q1;
    //-------------------------------------------------------------------------
    do{
    stake = kdr.valgetint("\nplease enter the amount you would like to begin betting with min 1 max 1000:");
    }while(stake<1 || stake>1000);
    //-------------------------------------------------------------------------
    //-------------------------------------------------------------------------
    do{
    System.out.print ("\nplease enter what you would like to bet\n1:number\n2:colour");
    Q1 = kdr.valgetint("\nplease input answer now: ");
    //-------------------------------------------------------------------------
    if(Q1 == 1)
    {
    do{
    Q2 = kdr.valgetint("\nplease input you number now: ");
    }while(Q1>=36);
    
    do{
    bet = kdr.valgetint("\nplease input you bet now: ");
    }while(bet<=stake);
    
    
    num = (int)(Math.random() * 36) + 1;
    
    if (num == Q2)
    {
    	if(num==2||num==4||num==6||num==8||num==10||num==11||num==13||num==15||num==17||num==20||num==22||num==24||num==26||num==28||num==29||num==31||num==33||num==35)
    	{
    	System.out.print ("\n"+num+" black");
    	System.out.print ("\nyou win!!!!");
    	stake = stake + (bet * 36);
    	System.out.print ("\nyour balance is "+stake+"");
    	}
    
    	else
    	{
    	System.out.print ("\n"+num+" red ");
    	System.out.print ("\nyou win!!!!");
    	stake = stake +(bet * 36);
    	System.out.print ("\nyour balance is "+stake+"");
    	}
    }
    XML Code:
    <a href="http://www.ubuntu.com/">ubuntu ftw</a>
    :cool:

  2. #2
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    Default

    I'm not sure I understand your problem. Have you tried debugging your program by using println() to show the values of the variables like num.

    Can you copy and paste the console from when you execute the program and add comments to it to show where the problem is?

  3. #3
    manowar689 is offline Member
    Join Date
    Jun 2010
    Posts
    16
    Rep Power
    0

    Default thanks for the reply

    i believe this is the problem so say the stake is 500 i want this to not proceed unless the bet is less then or equal to 500 and it wont proceed unless its greater then or equal to ?
    thx btw
    Java Code:
    do{
    bet = kdr.valgetint("\nplease input you bet now: ");
    }while(bet<=stake);
    XML Code:
    <a href="http://www.ubuntu.com/">ubuntu ftw</a>
    :cool:

  4. #4
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    Default

    Did you add a println() to the code to show the values of bet and stake?
    How do you know what they are in the program?

  5. #5
    manowar689 is offline Member
    Join Date
    Jun 2010
    Posts
    16
    Rep Power
    0

    Default

    this part sets the stake here kdr.valgetint simply just ensures that a valid interger is entered is all
    Java Code:
    stake = kdr.valgetint("\nplease enter the amount you would like to begin betting with min 1 max 1000:");
    }while(stake<1 || stake>1000);
    this part takes the bet and then i want it to ask it again until the bet is less then the stake the stake being money in the persons pocket if that makes sense
    Java Code:
    do{
    bet = kdr.valgetint("\nplease input you bet now: ");
    }while(bet<=stake);
    and wat difference would that make if i used println() ?? i am really new lol
    XML Code:
    <a href="http://www.ubuntu.com/">ubuntu ftw</a>
    :cool:

  6. #6
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    Default

    what difference would that make if i used println()
    The difference is that you would see what the values are and maybe understand what the problem is.

  7. #7
    manowar689 is offline Member
    Join Date
    Jun 2010
    Posts
    16
    Rep Power
    0

    Default

    do you mean like a line like this

    Java Code:
    println("+stake+")
    or just
    Java Code:
    println()
    i assume this is just a print line command yes?
    i use a keyboard.class which requires system.out.print so sorry if thats a noob question lol

    thx again D:D
    XML Code:
    <a href="http://www.ubuntu.com/">ubuntu ftw</a>
    :cool:

  8. #8
    manowar689 is offline Member
    Join Date
    Jun 2010
    Posts
    16
    Rep Power
    0

    Default

    the error for
    Java Code:
    println()
    was
    Java Code:
    cannot find symbol method println()
    and for
    Java Code:
    println()
    the error was
    Java Code:
    cannot find symbol method println(java.lang.String)
    hope this helps
    XML Code:
    <a href="http://www.ubuntu.com/">ubuntu ftw</a>
    :cool:

  9. #9
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    Default

    System.out.println(...) is so commonly used for debugging I didn't imagine that anyone wouldn't know how to use it.

  10. #10
    manowar689 is offline Member
    Join Date
    Jun 2010
    Posts
    16
    Rep Power
    0

    Default

    i just wasnt too sure thats why i asked im pretty much self taught so the lingo gets me sometimes i did try that and gave the outputs of both in my last post
    XML Code:
    <a href="http://www.ubuntu.com/">ubuntu ftw</a>
    :cool:

  11. #11
    manowar689 is offline Member
    Join Date
    Jun 2010
    Posts
    16
    Rep Power
    0

    Default

    o sorry yes but this wouldnt solve my problem and the kdr.valgetint works fine in all my other programs
    XML Code:
    <a href="http://www.ubuntu.com/">ubuntu ftw</a>
    :cool:

  12. #12
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    Default

    this wouldnt solve my problem
    No.It doesn't.
    It's to help you solve the problem. Its a technique called debugging. Many programmers use these kinds of techniques to solve their problems. First you need to understand what the program is doing, then you can change it to do what you want it to do.

    Have you put the println() in the code and observed the output?

  13. #13
    manowar689 is offline Member
    Join Date
    Jun 2010
    Posts
    16
    Rep Power
    0

    Default

    here are the files if you would like to try it and let me know lol
    :confused:
    Attached Files Attached Files
    XML Code:
    <a href="http://www.ubuntu.com/">ubuntu ftw</a>
    :cool:

  14. #14
    Norm's Avatar
    Norm is offline Moderator
    Join Date
    Jun 2008
    Location
    SW Missouri
    Posts
    17,412
    Rep Power
    25

    Default

    Sorry, not interested.
    We here to help you solve your problems. If you've solved your problem please mark this thread as solved.

    Good luck.

Similar Threads

  1. Making a program out of a Java Applet
    By Bomber_Will in forum Java Applets
    Replies: 1
    Last Post: 07-16-2009, 02:54 AM
  2. online ROULETTE CALCULATER
    By dysfunktional in forum Java Applets
    Replies: 2
    Last Post: 05-13-2009, 09:49 AM
  3. Making the program
    By pheonix in forum Advanced Java
    Replies: 4
    Last Post: 04-18-2009, 06:36 AM
  4. Help Making a program not crash
    By Lifeis2evil in forum New To Java
    Replies: 2
    Last Post: 12-10-2008, 03:10 AM
  5. Need help with Java classes for making a program.
    By TheDarkReverend in forum Advanced Java
    Replies: 2
    Last Post: 11-28-2008, 04:50 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
  •