// Yazzy Latif // 07/22/2020 // CSE142 // TA: Grace Hopper // This program simulates a simplified version of European Roulette in which the player always bets // on "low." import java.util.*; public class Roulette { public static void main(String[] args) { Random r = new Random(); int money = 10; int max = money; // the biggest number I've seen so far while (money > 0) { // if i have at least $3 then bet $3, otherwise bet what I have left int bet = Math.min(3, money); // spin roulette wheel int spin = r.nextInt(37); // 0, 1, 2, ... 36 // PLAYING AS HOUSE boolean playerWins = spin <= 18 && spin != 0; if (!playerWins) { money += bet; // house wins } else { money -= bet; // house loses } // update the max // max = Math.max(money, max); if (money > max) { max = money; } System.out.println("spin was " + spin + ", bet was: " + bet + ", balance is: " + money); } System.out.println("maximum balance was = " + max); } }