Roulette C Program



ProgramProgram

C genetic-algorithm genetic-programming evolutionary-algorithms evolutionary-computation roulette-wheel-algorithm tournament-algorithm elitism-algorithm Updated Oct 6, 2019 C. C# (CSharp) RouletteGame Roulette - 5 examples found. These are the top rated real world C# (CSharp) examples of RouletteGame.Roulette extracted from open source projects. You can rate examples to help us improve the quality of examples. Re: Roulette Posted 20 October 2007 - 01:55 PM In addition to manheave's advice, please note that the assignment operator (=) is different than the equality operator (). Click on the 'Update' button. When clicking on it, a new name roulette wheel will be generated. Second, to use it: By now you've set it up. Simply click on the wheel (it doesn't matter where you click) and it will spin. The selected entry will show up on the screen. You can choose to remove it from the wheel by using the 'Remove' button. Roulette is one of the oldest and most popular casino games in the world. It is also one of the simplest to play. In Roulette you place your bet on a number, row, line, or adjacent numbers. After bets are placed, the Roulette wheel is spun and the ball is dropped. The ball will then stop in a number slot and that number is the winning number.

ProgramRoulette
RouletteGame.java

Roulette Game C Program

importjava.util.Random;
importjava.util.Scanner;
publicclassRouletteGame
{
publicstaticvoidmain(String[] args)
{
Scanner keyboard =newScanner(System.in);
Random generator =newRandom();
double total =500;
double amount;
int choice, win =0, lose =0, spin =0;
int number;
int rouletteNum;
int result;
char response ='y';
int resultArr[] =newint[36];
while (response 'y'|| response 'Y'&& total <=0)
{
System.out.print('Enter your bet amount: ');
amount = keyboard.nextDouble();
System.out.print('0 - Evenn1 - Oddn2 - Numbern');
choice =-1;
while (choice <0|| choice >2)
{
System.out.print('Place your bet on: ');
choice = keyboard.nextInt();
}
number =0;
if (choice 2)
{
while (number <1|| number >36)
{
System.out.print('Place your bet on number(1-36): ');
number = keyboard.nextInt();
}
}
rouletteNum = generator.nextInt(37);
spin++;
System.out.println('Roulette number: '+ rouletteNum);
if (choice 2)
{
if (rouletteNum number)
result =35;
else
result =0;
}
else
{
if (rouletteNum 0|| rouletteNum %2!= choice)
result =0;
else
result =1;
}
//Print out game result, win/lose amount
if (result >0)
{
System.out.println('Congratulatons!!! You win!');
System.out.printf('You have won $%.2f n', result * amount);
System.out.printf('Here's your money back: $%.2f n',
(result +1) * amount);
total = (result +1) * amount + total;
win ++;
resultArr[rouletteNum]++;
}
else
{
System.out.println('You lose. Better luck next time!');
System.out.printf('You have lost $%.2f n',
(result +1) * amount);
total = total - (result +1) * (amount);
lose ++;
resultArr[rouletteNum]++;
if (total <=0) {
break;
}
}
//Ask for another game
for (int totals=1; totals<36; totals++) {
if( resultArr[totals] >0 ) {
System.out.println('The number '+ totals +' won '+ resultArr[totals] +' times.');
}
}
System.out.println('You hayve $'+ total +' remaining.' );
System.out.println('You have won '+ win +' games.');
System.out.println('You have lost '+ lose +' games.');
System.out.println('The wheel has been spun '+ spin +' times.');
System.out.print('nWould you like to play another game? (y/n) ');
response = keyboard.next().charAt(0);
}
}
}

Roulette Program

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment