Public class crapsgame {public static int roll () {return (INT) (math. random () * 6 + 1);} public static void main (string [] ARGs) {nation SC = New Nation (system. in); int money = 10000; int ante = 0; int firstpoint, currentpoint; Boolean sequel = true; do {Boolean goon = false; firstpoint = currentpoint = roll () + roll (); system. out. print ("You have" + money + "yuan now, Please bet:"); ante = SC. nextint (); system. out. println ("player Shake out: "+ firstpoint +" point "); Switch (firstpoint) {Case 7: Case 11: system. Out. println (" win !!! "); Money + = ante; break; Case 2: Case 3: Case 12: system. Out. println (" banker wins !!! "); Money-= ante; break; default: goon = true; break;} while (goon) {currentpoint = roll () + roll (); system. out. println ("Player SHAKE:" + currentpoint + "point"); If (currentpoint = 7) {system. out. println (""); money-= ante; goon = false;} else if (currentpoint = firstpoint) {system. out. println ("Players win !!! "); Money + = ante; goon = false;} system. out. println ("now available" + money + "Yuan"); If (money <= 0) {system. out. println ("you have already lost. Gambling is over !!! ");} Else {system. Out. println (" continue? 1, continue 2, do not continue ");} int x = SC. nextint (); If (x = 1) {sequel = true;} else {sequel = false ;}} while (sequel );}}
Craps gambling games