
I need a java program for a Craps game
When the program is run, it will prompt the player for the starting balance of their account (in dollars).
At the start of each game, the player will be asked for their bet. The bet must be at least $1, but cannot exceed the balance of their account
During the game, the outcome of each roll must be output to the display.
When the outcome of the game is decided, the account balance must be updated accordingly based on the player’s bet. If the player wins, the amount of the bet is added to the account balance; if the player loses, the account balance is decreased by the bet amount.
At the end of each game, the game outcome must be summarized (e.g., player wins or loses), along with the player’s updated account balance.
The player will continue to play Craps games until one of the following conditions occur:
They voluntarily elect to end the session. After each game, once all required information has been output, the player will be prompted to play another game or to end the session.
Their account balance goes to zero. In this case, the program will automatically terminate the session
At the conclusion of the session, the program will output the following information before terminating:
Number of games played
Percentage of games won and lost
Current account balance
Percentage increase or decrease in account balance since the session began.
The Math.random() method must be used to generate the value for each dice roll.
During the game, the outcome of each dice roll must be output to the display, nominally one line of output text per roll. Likewise, the outcome of the game must be summarized (player win or lose).
Have the rolls initated automatically or manually(pressing the R key to do this)
The program must make use of dialog and message boxes (JOptionPane class). Prompts for input to the user (e.g., taking bets) should employ these devices. At least one JOptionPane instance must be used in your program.
Rules for the Game:
At the start of the game, the player rolls two dice. Let x be sum of those dice.
If x is 7 or 11, the player wins instantly
If x is 2, 3, or 12, the player loses instantly
If the sum is any other number, the player repeatedly rolls two dice until sum is either x or
If sum is x then the player wins
If the sum is 7 then the player loses
Game Output: (It doesn't need to be exactly like this)
Do you wish to play another game? y
Please input your bet for the game >> $100
Invalid bet – Your balance is only: $50
Please input your bet for the game >> $25
Game #9 starting with bet of: $25.00
Player rolls: 11
Player wins :-^) !
Your account balance is now: $75
Do you wish to play another game? y
Please input your bet for the game >> $75
Game #10 starting with bet of: $75.00
Player rolls: 10 -- must roll 10 again to win
Player rolls: 12
Player rolls: 3
Player rolls: 7
Player loses :-((
Your account balance is now: $ 0.00
Sadly, you are no longer eligible to play
Your ending account balance is: $ 0.00
Your starting balance has decreased by $200.00 (-100%)
Of the 10 games played, you have won 3 games (30.0 %) and lost 7 games (70.0 %)
Buh, bye – Get more $$ and play again soon!
Exceptions: This is what I created for any potential errors.
String response;
while (true)
{
response = JOptionPane.showInputDIalog("Enter your strating account balance ($)");
try
{
startBalance = Double.parseDouble(response);
}
catch (NullPointerExcpetion e)
{
System.out.println("Error: The box cannot be empty!");
continue;
}
catch (NumberFormatException e)
{
System.out.println("Error: You must enter a numeric value in the box!");
continue;
}
if (startBalance >= MIN_INIT_BALANCE)
break;
System.out.printf("Please enter at least $%5.2f for a starting balance\n", MIN_INIT_BALANCE);

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

- Rock, Paper, Scissors Game Create a application using (C#) in Microsoft Visual Studio that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows.1. When the program begins, a random number in the range of 1 through 3 is generated. If the number is 1, then the computer has chosen rock. If the number is 2, then the computer has chosen paper. If the number is 3, then the computer has chosen scissors. (Do not display the computer’s choice yet.)2. The user selects his or her choice of rock, paper, or scissors. To get this input you use clickable PictureBox controls displaying some of the artwork that you will find in the student sample files.3. The computer’s choice is displayed.4. A winner is selected according to the following rules: •If one player chooses rock and the other player chooses scissors, then rock wins. (Rock smashes scissors.)•If one player chooses scissors and the other player chooses paper, then scissors wins.…arrow_forwardMicrofost Visual C# 7th edition programming exercise 6-10. I need help, please. This problem relies on the generation of a random number. You can create a random number that is at least min but less than max using the following statements: Random ranNumberGenerator = new Random();int randomNumber;randomNumber = ranNumberGenerator.Next(min, max); Create a game similar to Hangman named GuessAWord in which a player guesses letters to try to replicate a hidden word. Store at least eight words in an array, and randomly select one to be the hidden word. Initially, display the hidden word using asterisks to represent each letter. Allow the user to guess letters to replace the asterisks in the hidden word until the user completes the entire word. If the user guesses a letter that is not in the hidden word, display an appropriate message. If the user guesses a letter that appears multiple times in the hidden word, make sure that each correct letter is placed. Figure 6-27 shows a typical game…arrow_forwardPYTHON CODE Reza Enterprises sells tickets for buses, tours, and other travel services. Because Reza frequently mistypes long ticket numbers, Reza Enterprises has asked his students to write an application that shows if a ticket is invalid. Your application/program tells the ticket agent to enter a six-digit ticket number. Ticket numbers are designed so that if you lose the last digit of the number, then divide by 7, the remainder of the division is exactly the same to the last dropped digit. This process is shown below: Step 1: Enter the ticket number; for example 123454 Step 2: Remove the last digit, leaving 12345 Step 3: Determine the remainder when the ticket number from step 2 is divided by 7. In this case, 12345 divided by 7 leaves a remainder of 4. Step 4: Display a message to the ticket agent indicating whether the ticket number is valid or not. If the ticket number is valid, save the number to a .txt file called “tickets.txt” and continue to loop your program asking…arrow_forward
- Validating User Input Summary In this lab, you will make additions to a Java program that is provided. The program is a guessing game. A random number between 1 and 10 is generated in the program. The user enters a number between 1 and 10, trying to guess the correct number. If the user guesses correctly, the program congratulates the user, and then the loop that controls guessing numbers exits; otherwise, the program asks the user if he or she wants to guess again. If the user enters a "Y", he or she can guess again. If the user enters "N", the loop exits. You can see that the "Y" or an "N" is the sentinel value that controls the loop. Note that the entire program has been written for you. You need to add code that validates correct input, which is "Y" or "N", when the user is asked if he or she wants to guess a number, and a number in the range of 1 through 10 when the user is asked to guess a number. Instructions Ensure the file named GuessNumber.java is open. Write loops…arrow_forwardRock, Paper, Scissors Game - MUST BE WRITTEN IN PSEUDOCODEarrow_forwardPlease help me to code this Python It is High/Low Card Game The pyex is example of outputarrow_forward
- Hands-On Activity 4-4 BuzzButtons is a novelty item company manufacturing personalized lapel buttons that buzz randomly. The buttons are marketed as a conversation starter, and the company's slogan is "It starts the buzz!" The owner is promoting his buttons by offering them at 99 cents each. He wants you to design a program asking the user for his or her name for the button, an e-mail address, and the number of buttons to order. The program should then add a 6% sales tax and a flat shipping rate of $2.00. The program displays the information the user enters as well as the button price total, sales tax amount, shipping amount, and order total. The company contacts the user by e-mail later for shipping address information. Using pseudocode, design an algorithm that asks the user for the number of fixed-price items to order, adds sales tax and flat-rate ship- ping, and displays the result. Save your pseudocode file in Notepad as buzzButtons.txt.arrow_forwardJava coding platformarrow_forwardJava - Name Formatarrow_forward
- JAVA PROGRAM Your task is to make a point calculator which takes a point in the 1st quadrant and then finds its position in user entered quadrant.arrow_forwardJava:arrow_forwardCSCI 140/L Java Project: Menu-Driven System Part A Write a menu-driven program that will give the user the three choices: 1) Wage calculator, 2) Coupon Calculator, and 3) Exit. Class Name: PartA Wage Calculator: For the wage calculator, prompt for the name and hourly pay rate of an employee. Here the hourly pay rate is a floating-point number, such as $9.25. Then ask how many hours the employee worked in the past week. Be sure to accept fractional hours. Compute the pay. Any overtime work (over 40 hours per week) is paid at 150 percent of the regular wage (1.5 the hourly pay rate). Print the employee's name, regular hours worked, regular hours pay, overtime hours worked (do not show overtime hours, if there are none), overtime hours pay (do not show overtime pay if there is none), and total pay. [Do not prompt for overtime hours] Coupon Calculator: For the coupon calculator, the total coupon amount is calculated based on the type of items purchased. Ask for the shopper's total purchase…arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education





