Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Computer Engineering Expert

Need help with Intro to Java problem:

Craps is a dice-based game played in many casinos. Like blackjack, a player plays against the house. The game starts with the player throwing a pair of (that is, two distinct) standard, six-sided dice. (Note that throwing a single 12-sided die will not result in the same probabilities of winning/losing. Don't do this!)

If the player rolls a total of 7 or 11 in the first round, the player wins. If the player rolls a total of 2, 3, or 12 in the first round, the player loses.

For all other roll values, the player must roll again to determine whether he/she has won or lost. In the second and subsequent rounds the player rolls the pair of dice again.

If the player matches the roll value from the first round again, she/he wins. If the player rolls a 7, he/she loses. Play continues into another round until the initial roll is matched (for a win) or a 7 is rolled (for a loss).

Write a craps() function that plays a game of craps as described above. The function should continue rolling as described in the rules above until it has determined that the player has won or lost. If the function determines that the player has lost, it should return 0. If the function determines that the player has won, it should return 1.

The main method I have provided calls the craps() function and reports the outcome based on what the function returns. It also tracks how many rounds the player has won and how many the player has lost. Do not change the main() method. Your only task is to correcly implement the craps() function.

Note: The craps function needs to always return a value, which means that you can't have return statements only in branches. If you return in branches, you also need to have a return of some bogus value at the very end of the function.

Java enforces that functions that return integers (or anything other than void) actually return something and branching statements can mess things up.

Computer Engineering, Engineering

  • Category:- Computer Engineering
  • Reference No.:- M93063587

Have any Question?


Related Questions in Computer Engineering

Question suppose an instruction can be carried out in 3

Question : Suppose an instruction can be carried out in 3 stages, the stages taking 3 ns, 7 ns, and 10 ns, respectively. (a) What is the maximum execution rate without pipelining? (b) What speedup is possible with pipeli ...

A string in c is simply an array of characters with the

A string in C++ is simply an array of characters with the null character(\0) used to mark the end of the string. C++ provides a set of string handling function in as well as I/O functions in . With the addition of the ST ...

Please help with anbspfunctionnbspcodesymbol to convert

Please help with a function  codeSymbol , to convert each mark to a symbol (A, B, C, D, E, F) and a code (7,6,5,4,3,2,1) according to the table below. And call it in the main function. Use the table below to determine th ...

Question develop a taxonomy of dsia document a taxonomy is

Question: Develop a "taxonomy" of DS/IA document. A taxonomy is a way of organizing something on a "group within group" basis. (Remember how the biological taxonomy is structured.) Initially, define data security and inf ...

Design a combinational circuit with three inputs a b and c

Design a combinational circuit with three inputs: A, B, and C, D and the output W. The output should be 1 only when the values of A, B interpreted as an unsigned integer (AB) is equal to the values of C, D interpreted as ...

After reading the case presented in the module write a

After reading the case presented in the module, write a short response to the following discussion questions and ethical decision making scenario. Discussion Questions What project management tasks should Kelvin perform ...

Strings in cstrings manipulationwrite one main code with

Strings in C++ Strings manipulation Write one main code with the following functions. Toggle Write a function called toggle() that accepts a string, and an integer. The function checks whether the character at the positi ...

Advertisements suggest that a new window design can save

Advertisements suggest that a new window design can save $400 per year in energy cost over its 30-year life. At an initial cost of $8,000 and zero salvage value, using IRR, is this window a good investment? MARR is 8%.

Question the subnet mask for a class c network is

Question : The subnet mask for a class C network is 255.255.255.248. How many subnetworks are available? How many assignable hosts ids per subnet? The response must be typed, single spaced, must be in times new roman fon ...

In defining demand and supply why do economists focus on

In defining demand and supply, why do economists focus on price while holding constant other factors that might have an impact on the behavior of buyers and sellers?

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As