Roulette C Program 4,3/5 2019 reviews

Blackjack C++ Program
RouletteGame.java
Roulette Game C Program

Roulette Program
Roulette Game (c Programming)The roulette wheel has the numbers 0-36 on it.you can place your bet in one of three ways:i. Bet on a number (payout is 36 times the bet amount)ii. Bet on an odd or even (payout is 2 times the bet)iii. Bet on a dozen first 1-12, second 13-24, third 25-36 (payout is 3 times the bet)The number zero does not count for odd or even or dozen, but can count as a number bet. Write a program in C using the following information The roulette wheel has the numbers 0-36 on it You can place your bet in one of three ways i. Bet on it a number (payout is 36 times the bet amount).
| 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 Download Free
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment