Question: Need help writing this Java program. Any help would be greatly appreciated. You will be writing a Java program that plays the dice game High-Low.

Need help writing this Java program. Any help would be greatly appreciated.

You will be writing a Java program that plays the dice game High-Low. In this game the player places a wager on whether the dice will come up High (total 8 or higher), Low (total 6 or lower) or Sevens (total exactly 7).

For this lab you will write a Java program that plays the dice game High-Low. In this game a player places a bet on whether the sum of two dice will come up High (totalling 8 or higher), Low (totalling 6 or less) or Sevens (totalling exactly 7). If the player wins, he receives a payout based on the schedule given in the table below:

Choice Payout
High 1 x Wager
Low 1 x Wager
Sevens 4 x Wager

The player will start with $100 for wagering. If the player chooses to wager $0 or if he runs out of money, the program should end. Otherwise it should ask him whether he's wagering on High, Low or Sevens, display the results of the die rolls, and update his money total accordingly. For this assignment you must start with the following "skeleton" of Java code.

/* * Project07.java * * A program that plays the dice game high/low * Used to practice breaking code up into methods. * * @author ENTER YOUR NAME HERE * */ package cse; import java.util.Scanner; public class Project07 { public static void main(String[] args) { // Fill in the body } // Given a Scanner and a current maximum amount of money, prompt the user for // an integer representing the number of dollars that they want to bet. This // number must be between 0 and to maximum number of dollars. If the user enters // a number that is out of bounds, display an error message and ask again. // Return the bet to the calling program. private static int getBet(Scanner inScanner, int currentPool) { // Fill in the body } // Given a Scanner, prompt the user for a single character indicating whether they // would like to bet High ('H'), Low ('L') or Sevens ('S'). Your code should accept // either capital or lowercase answers, but should display an error if the user attempts // to enter anything but one of these 3 values and prompt for a valid answer. // Return the character to the calling program. private static char getHighLow(Scanner inScanner) { // Fill in the body } // Produce a random roll of a single six-sided die and return that value to the calling // program private static int getRoll() { // Fill in the body } // Given the choice of high, low or sevens, the player's bet and the total result of // the roll of the dice, determine how much the player has won. If the player loses // the bet then winnings should be negative. If the player wins, the winnings should // be equal to the bet if the choice is High or Low and 4 times the bet if the choice // was Sevens. Return the winnings to the calling program. private static int determineWinnings(char highLow, int bet, int roll) { // Fill in the body } } 

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!