Problem IN JAVA - in The Game of - C-R-A-P-S - (Chegg...
Problem IN JAVA - in The Game of - C-R-A-P-S - (Chegg...
com
NEW!
Textbook Solutions Expert Q&A Study Pack Practice
home / study / engineering / computer science / computer science questions and answers / problem in java : in the game of "c-r-a-p-s"(chegg wo…
Question: Problem IN JAVA : In the game of "c-r-a-p-s"(Chegg won't let … Post a question
Answers from our experts for your tough
homework questions
See this question in the app
Enter question
Problem IN JAVA
: In the game of "c-r-a-p-s"(Chegg won't let me post the actual word), a pass line bet proceeds as follows.
Two six sided dice are rolled: the rst roll of the dice in a c-r-a-p-s round is called the “come out roll.” A Continue to post
come
20 questions remaining
out roll of 7 or 11 automatically wins, and a come out roll of 2, 3, or 12 automatically
loses. If 4, 5, 6, 8, 9, or 10 is rolled on the come out roll that number becomes “the
point.” The player keeps rolling the dice until either 7 or the point is rolled. If the point is
rolled rst, then the player wins the bet. If a 7 is rolled rst, then the player loses. Snap a photo from your
phone to post a question
Write a program that simulates a game of c-r-a-p using these rules without human input.
We'll send you a one-time download
Instead of asking for a wage, the program should calculate whether the player would win link
or lose. The program should simulate rolling two dice and calculate the sum. Add a loop
so that the program plays 10,000 games. Add counters that count how many times the 888-888-8888 Text me
player wins, and how many times the player loses. At the end of the 10,000 games,
By providing your phone number, you agree to receive a one-time
compute the probability of winning (wins/ (wins + losses)) and out put this value. automated text message with a link to get the app. Standard
messaging rates may apply.
Note: to simulate the dice rolling use Random class to generate numbers between 1 and 6
inclusive or you can use the random method from the Math class.
Here is an example series:
The shooter throws the dice on a come out roll, which starts a new series, and a 5 is rolled. (Recall that My Textbook Solutions
rolling a 7 or 11 would have been winners and 2, 3, or 12 would have been losers.)
The shooter has established a Point of 5.
The shooter throws the dice again and rolls an 8.
Nothing happens and player rolls the dice again.
Laboratory... Electronic... Signals and...
The shooter throws the dice again and rolls a 3. (Note that rolling a 2, 3, 11, or 12 after a point is established
means nothing ) 9th Edition 11th Edition 2nd Edition
https://www.chegg.com/homework-help/questions-and-answers/problem-java-game-c-r-p-s-chegg-won-t-let-post-actual-word-pass-line-bet-proceeds-follows--q28523272 1/12
10/27/2020 Problem IN JAVA : In The Game Of "c-r-a-p-s"(Chegg... | Chegg.com
The shooter throws the dice again and rolls a 5. View all solutions
NEW!
This Textbook
is the shooter's point so Solutions
this is a win Expert
and the series ends.Q&A Study Pack Practice
https://www.chegg.com/homework-help/questions-and-answers/problem-java-game-c-r-p-s-chegg-won-t-let-post-actual-word-pass-line-bet-proceeds-follows--q28523272 2/12
10/27/2020 Problem IN JAVA : In The Game Of "c-r-a-p-s"(Chegg... | Chegg.com
for (int i =0; i< 10,000; i++)
{ Textbook Solutions
NEW!
Expert Q&A Study Pack Practice
* Since you roll the dice two times you need to generate two
random numbers between 1 and 6 inclusive and then add them
up. This will be the value for the variable
comeOutRol
* Call the method winOrLoss
based on the returned value from this method:
* increment the variable numOfWins
* or increment the variable numOfLoss
* or set the variable thePoint to comeOutRoll and then call the method keepRolling.
Based on the value returned from this method adjust the value of numOfLoss and NumOfWin
}
call the method winProability
output the return value from the method winProability
reset all the variables
ask the user if he/she wants to start another set of games
}
3. winOrLoss method: in this method you can only have one return statement.
public static String winOrLoss(int comeOutRoll)
{
// if comeOutroll is 7 or 11 return “win”
//if comeOutRoll is 2, 3, or 12 return the string “Loss”
//if comeOutRoll is 4, 5, 6,8, 9, or 10 return the string”the point”
}
4. description method: outputs the description of the game
public static void description()
{
//output the description
}
5. KeepRolling method : you must only use one return statement.
public static String(int thePoint)
{
//keep rolling the dice until you get thePoint or your get seven.
//return the string “seven” if you get a seven
//return the string “thePoint” if you get the point
https://www.chegg.com/homework-help/questions-and-answers/problem-java-game-c-r-p-s-chegg-won-t-let-post-actual-word-pass-line-bet-proceeds-follows--q28523272 3/12
10/27/2020 Problem IN JAVA : In The Game Of "c-r-a-p-s"(Chegg... | Chegg.com
}
NEW!
6. winProability method : Textbook Solutions Expert Q&A Study Pack Practice
In the simulation we :
won 14722 times
lost 15278 times,
for a probability of 0.4907
Hit enter key to continue
Would you like to play another game yes/no? no
Have a nice day. GoodBye
Expert Answer
/*
*/
package crapsgame;
import java.util.Random;
import java.util.Scanner;
/**
* @author Vishalkumar.Jain
*/
/**
/**
* @param comeOutRoll
* @return result
*/
switch (comeOutRoll) {
case 7:
case 11:
return "win";
case 2:
case 3:
case 12:
return "loss";
default:
return "thepoint";
/**
*/
https://www.chegg.com/homework-help/questions-and-answers/problem-java-game-c-r-p-s-chegg-won-t-let-post-actual-word-pass-line-bet-proceeds-follows--q28523272 6/12
10/27/2020 Problem IN JAVA : In The Game Of "c-r-a-p-s"(Chegg... | Chegg.com
public static void description() {
NEW!
Textbook Solutions Expert Q&A Study Pack Practice
System.out.println("Computer will play a c-r-a-p game for you. Here are the\n"
+ "\n"
+ "\n"
+ "\n"
+ "\n"
+ "round\n"
+ "\n"
+ "\n"
+ "\n"
+ "\n"
+ "If the player gets the point he/she will keep playing by\n"
+ "\n"
+ "\n"
+ "If the point is rolled rst, then the player wins the\n"
+ "\n"
+ "bet.\n"
+ "\n"
+ "\n"
https://www.chegg.com/homework-help/questions-and-answers/problem-java-game-c-r-p-s-chegg-won-t-let-post-actual-word-pass-line-bet-proceeds-follows--q28523272 7/12
10/27/2020 Problem IN JAVA : In The Game Of "c-r-a-p-s"(Chegg... | Chegg.com
}
NEW!
Textbook Solutions Expert Q&A Study Pack Practice
/**
* This method keeps rolling the dices until the number comes out
* @param thepoint
* @return string value based on the outcome of the dices at the end
*/
int num;
do {
num = rollDices();
/**
* @return winProbability
*/
return probability;
/**
*/
numOfPlays++;
https://www.chegg.com/homework-help/questions-and-answers/problem-java-game-c-r-p-s-chegg-won-t-let-post-actual-word-pass-line-bet-proceeds-follows--q28523272 8/12
10/27/2020 Problem IN JAVA : In The Game Of "c-r-a-p-s"(Chegg... | Chegg.com
boolean playagain = true;
NEW!
Textbook Solutions Expert Q&A Study Pack Practice
while (playagain) {
comeOutRoll = rollDices();
switch (winOrLose(comeOutRoll)) {
case "win":
numOfwin++;
break;
case "lose":
numOfLoss++;
break;
case "thepoint":
thePoint = comeOutRoll;
if (result.equals("thepoint")) {
numOfwin++;
} else {
numOfLoss++;
break;
do {
https://www.chegg.com/homework-help/questions-and-answers/problem-java-game-c-r-p-s-chegg-won-t-let-post-actual-word-pass-line-bet-proceeds-follows--q28523272 9/12
10/27/2020 Problem IN JAVA : In The Game Of "c-r-a-p-s"(Chegg... | Chegg.com
System.out.println("Would you like to play another game yes/no? ");
NEW!
Textbook Solutions Expert Q&A Study Pack Practice
Scanner sc=new Scanner(System.in);
if (ans.toLowerCase().equals("no")) {
} else if (ans.toLowerCase().equals("yes")) {
inCorrectInput = false;
} while (inCorrectInput);
description();
play();
Q: Problem IN JAVA : In the game of "c-r-a-p-s"(Chegg won't let me post the actual word), a pass line bet proceeds as
follows. Two six sided dice are rolled: the rst roll of the dice in a c-r-a-p-s round is called the “come out roll.” A come
out roll of 7 or 11 automatically wins, and a come out roll of 2, 3, or 12 automatically loses. If 4, 5, 6, 8, 9, or 10 is rolled
on the come...
https://www.chegg.com/homework-help/questions-and-answers/problem-java-game-c-r-p-s-chegg-won-t-let-post-actual-word-pass-line-bet-proceeds-follows--q28523272 10/12
10/27/2020 Problem IN JAVA : In The Game Of "c-r-a-p-s"(Chegg... | Chegg.com
A: See answer
NEW!
Textbook Solutions Expert Q&A Study Pack Practice
In cryptarithmetic In cryptarithmetic
puzzles, puzzles,
mathematical equations mathematical equations
are are
writtenusing letters.Each written using letters.Each See more questions
letter can be a digit from letter can be a digit from for subjects you study
0 to 0 to
9, but no two letters can 9, but no two letters can
Q: Crap Game: Problem: In the game of craps, a pass line bet proceeds as follows. Two six sided dice are rolled: the rst
roll of the dice in a craps round is called the “come out roll.” A come out roll of 7 or 11 automatically wins, and a come
out roll of 2, 3, or 12 automatically loses. if 4, 5, 6,8,9, or 10 is rolled on the come out roll, that number becomes “the
point.” The player...
A: See answer
Q: In the game of craps, a pass line bet proceeds as follows. Two six-sided die are rolled: the rst roll of the dice in a
craps round is called the “come out roll.” A come out roll of 7 or 11 automatically wins, and a come out roll of 2, 3, or
12 automatically loses. If 4, 5, 6, 8, 9, or 10 is rolled on the come out roll that number becomes “the point.” The player
keeps rolling the...
A: See answer
Show more
https://www.chegg.com/homework-help/questions-and-answers/problem-java-game-c-r-p-s-chegg-won-t-let-post-actual-word-pass-line-bet-proceeds-follows--q28523272 11/12
10/27/2020 Problem IN JAVA : In The Game Of "c-r-a-p-s"(Chegg... | Chegg.com
NEW!
COMPANY Textbook Solutions Expert Q&A Study Pack Practice
CHEGG NETWORK
CUSTOMER SERVICE
https://www.chegg.com/homework-help/questions-and-answers/problem-java-game-c-r-p-s-chegg-won-t-let-post-actual-word-pass-line-bet-proceeds-follows--q28523272 12/12