// Miya Natsuhara // 07-19-2019 // 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 rand = new Random(); int money = 10; int max = money; // the biggest number I've seen so far while (money > 0) { int bet = Math.min(3, money); // bet $3 if I have it, otherwise just bet whatever I have left // spin roulette wheel int spin = rand.nextInt(37); // 0, 1, 2, ..., 36 // PLAYING AS HOUSE boolean playerWins = spin <= 18 && spin != 0; if (!playerWins) { // house wins money += bet; } else { // house loses money -= bet; } // updating the max // could instead use: // 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); } }