ITEC 1620 Lecture 14: Game

100 views3 pages

Document Summary

Craps is a popular dice game played in casinos. Write a program to play a variation of the game, as follows: Each die has six faces representing values (cid:616), (cid:617), , and 6, respectively. Continue to roll the dice until either a 7 or the same point value is rolled. Your program acts as a single player. public class exercise_06_30 { /** main method */ public static void main(string[] args) { // roll two dice int point = rolltwodice(); // check the sum of the two dice for craps or natural int result = getresult(point); // if result is craps or natural print result if (isnaturalorcraps(result)) printresult(result); else { // continue to roll dice till you win or lose rolltillwinorlose(result); /** method rolldice */ public static int rolldice() { // generate a random number between 1 to 6 return (int)(1 + math. random() * 6);

Get access

Grade+
$40 USD/m
Billed monthly
Grade+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
10 Verified Answers
Class+
$30 USD/m
Billed monthly
Class+
Homework Help
Study Guides
Textbook Solutions
Class Notes
Textbook Notes
Booster Class
7 Verified Answers

Related Documents