Find Us On: Facebook Twitter Rss Feed Blog
Need To Register? Sign Up Login

Simple Java program 2


use file Write a complete Java program that plays a simplified version of the casino game “Craps.” This game is played with a set of two perfectly balanced dice, each one a cube that has one side containing 1, 2, 3, 4, 5, or 6 black dots. Your program will “roll” two dice until the total value is 4, 5, 6, 8, 9, or 10. This number becomes the player’s “point.” After the point value has been obtained, the program continues to roll the dice until the total value of the dice is either: •7 (in which case you lose), or • it’s the “point” that was previously established (in which case you win). You should use the following method that was defined in lecture: static int rint (int a, int b) { return a + (int) ( (b-a+1) * Math.random() ); } You must define a method static int doRoll() { ... } that rolls *two* dice and returns the sum of the roll. You may not use any static class variables It is recommended that you use two separate while or do-while loops to implement this game. Here’s what the program might look like in action: % java Craps Computer rolls a 6 and a 5, for a total of 11. Computer rolls a 1 and a 2, for a total of 3. Computer rolls a 5 and a 1, for a total of 6. 6 is now the established POINT. Computer rolls a 4 and a 4, for a total of 8. Computer rolls a 2 and a 5, for a total of 7. You Lose Attachments
Tags Clarifications


Solution Craps


The solution is implemented based in the given requirements. Attachments (1 K) Download Preview
- a + 1) * Math.random()); } /** * Checks if a number is valid. * * @param number * The given number to be checked. * @return <code>True</code> if is a valid number, <code>False</code> * otherwise. */ static boolean isValidNumber(int number) { return (number == 4 || number

Screen Shot 2016-11-11 at 17.07.00.png (65 K) Download Preview

Purchase Answer