# Solved: Complete Problem 6.33 On Pages 254-255 Of Your Textbook. Make Sure That You Properly Document Your Program By Making Changes To What Is Given In The Problem And In The Figures That Contain The

By |

Complete problem 6.33 on pages 254-255 of your textbook. Make sure that you properly document your program by making changes to what is given in the problem and in the figures that contain the program code. Properly test your program to ensure that it works correctly. *) Note: You are to change the game so that it will run repeatedly until either the player runs out of money or if he/she chooses to quit. If the user chooses to quit, output a message thanking him/her for playing and displaying the amount cashed out. Additionally, add at least one other “chatter” statement that, like the ones given, will be randomly selected for printout once the user enters the bet amount.

Here is the program to be modified

(Craps Game Modification) Modify the craps program of Fig. 6.8 to allow wagering. Initialize variable bankBalance to 1000 dollars. Prompt the player to enter a wager. Check that wager is less than or equal to bankBalance, and if it’s not, have the user reenter wager until a valid wager is entered. Then, run one game of craps. If the player wins, increase bankBalance by wager and display the new balance. If the player loses, decrease bankBalance by wager, display the new bank-Balance, check whether bankBalance has become zero and, if so, display the message "Sorry. You busted!" As the game progresses, display various messages to create some “chatter,” such as "Oh, you’re going for broke, huh?" or "Aw c’mon, take achance!" or "You’re up big. Now’s the time to cash in your chips!". Implement the “chatter” as a separate method that randomly chooses the string to display.

here is a sample program to be modified. You can only additionally import the scanner

```1 // Fig. 6.8: Craps.java
2// Craps class simulates the dice game craps.
3import java.security.SecureRandom;
4
5public class Craps {
6  // create secure random number generator for use in method rollDice
7  private static final SecureRandom randomNumbers = new SecureRandom();
8
9  // enum type with constants that represent the game status
10  private enum Status {CONTINUE, WON, LOST};
11
12  // constants that represent common rolls of the dice
13  private static final int SNAKE_EYES = 2;
14  private static final int TREY = 3;
15  private static final int SEVEN = 7;
16  private static final int YO_LEVEN = 11;
17  private static final int BOX_CARS = 12;
18
19  // plays one game of craps
20  public static void main(String[] args) {
21     int myPoint = 0; // point if no win or loss on first roll
22     Status gameStatus; // can contain CONTINUE, WON or LOST
23
24     int sumOfDice = rollDice(); // first roll of the dice
25
26     // determine game status and point based on first roll
27     switch (sumOfDice) {
28        case SEVEN: // win with 7 on first roll
29        case YO_LEVEN: // win with 11 on first roll
30           gameStatus = Status.WON;
31           break;
32        case SNAKE_EYES: // lose with 2 on first roll
33        case TREY: // lose with 3 on first roll
34        case BOX_CARS: // lose with 12 on first roll
35           gameStatus = Status.LOST;
36           break;
37        default: // did not win or lose, so remember point
38           gameStatus = Status.CONTINUE; // game is not over
39           myPoint = sumOfDice; // remember the point
40           System.out.printf("Point is %d%n", myPoint);
41           break;
42     }
43
44     // while game is not complete
45     while (gameStatus == Status.CONTINUE) { // not WON or LOST
46        sumOfDice = rollDice(); // roll dice again
47
48        // determine game status
49        if (sumOfDice == myPoint) { // win by making point
50           gameStatus = Status.WON;
51        }
52        else {
53           if (sumOfDice == SEVEN) { // lose by rolling 7 before point
54              gameStatus = Status.LOST;
55           }
56        }
57     }
58
59     // display won or lost message
60     if (gameStatus == Status.WON) {
61        System.out.println("Player wins");
62     }
63     else {
64        System.out.println("Player loses");
65     }
66  }
67
68  // roll dice, calculate sum and display results
69  public static int rollDice() {
70     // pick random die values
71     int die1 = 1 + randomNumbers.nextInt(6); // first die roll
72     int die2 = 1 + randomNumbers.nextInt(6y); // second die roll
73
74     int sum = die1 + die2; // sum of die values
75
76     // display results of this roll
77     System.out.printf("Player rolled %d + %d = %d%n", die1, die2, sum);
78
79     return sum;
80  }
81}```