You will use the Casino.java (that is provided) to drive the Roulette class (tha
ID: 3659858 • Letter: Y
Question
You will use the Casino.java (that is provided) to drive the Roulette class (that you will create). Your job is to create the Roulette class to interact with the Casino class to allow the user to play the game of Roulette.
Here are the rules: Create a class named Roulette with a method named betOnce that takes, as parameters, the amount of the user bet.
Generate a random number between 0 and 36 (that simulates the wheel) The user should be prompted to place their bet on 1) Low or 2) High or 3) a Number If the user selected 3) a Number, prompt the user to enter a guess between 1 and 36. If the user selected 1) Low: And the number is between 1 & 18, the user wins and doubles their bet And the number is between 19 & 36, the user loses their bet And the number is 0, the user loses If the user selected 2) High: And the number is between 1 & 18, the user loses their best And the number is between 19 & 36, the user wins and doubles their bet And the number is 0, the user loses If the user selected 3) a Number and entered their guess: And the user guess matches the random number, they win 35 times their bet And the user guess does not match the random number, they lose their bet And the number is 0, the user loses Return the users winnings/losses to the console from the betOnce method and write/append the results to a text file named results.txt. Submit your Roulette.java file.
Explanation / Answer
import java.io.*; import java.lang.Math.*; import java.util.Scanner; public class Roulette { public static void main(String args[]) { Roulette r=new Roulette(); System.out.println("Enter the bet amount"); Scanner in=new Scanner(System.in); int amt=in.nextInt(); r.betOnce(amt); } public static void betOnce(int amount) { double ran = Math.random(); double rand; rand = 36*ran; System.out.println("Enter Your choice 1.Low 2.High 3.Enter the number between 0 1nd 36"); int ch,ch2; Scanner in = new Scanner(System.in); ch =in.nextInt(); switch(ch) { case 1: if((amount>0)&&(amount18)&&(amountRelated Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.