19-6 / 27 Job: Gambling games perfect --- need to continue to improve

☞ code requires

Perfect codes beyond the input range after to reenter

 

 

☞ realization of ideas

While using the structure, it is determined whether the input conditions, if the condition does not meet the requirement to re-enter

 

 

☞ Code Content

 

Circulation Package; 

// import package
Import java.util.Scanner;

public class Dubo {
static Scanner Scanner new new SC = (the System.in);

public static void main (String [] args) {
. Casino prompt. 1 //

System. out.println ( "********** *********** Welcome to pull out wool Casino");

// 2 reminder recharge, the definition of principal
System.out.println ( "Please recharge");
int sc.nextInt Money = ();

.. 3 // into the circulation, shake the dice starts
the while (to true) {
int A = (int) (Math.random () * +. 1. 6);
int = B (int) (Math.random () * +. 1. 6);
int C = (int) (Math.random () * +. 6. 1);

.. 4 // calculate dice
int sum = a + b + c ;

// 5 point size determination
String result = sum <10 "small": "Big";?

// 6 remind bet.
System.out.println ( "Please select a size");
String GUESS = sc.next ();
the while ( "big"! ! .equals (guess) && "small" .equals (GUESS)) {
System.out.println ( "only bet size, do not mess charge, re-charge it:");
GUESS = sc.next ();
}
System .out.println ( "Place your bets, the amount of not less than 500");
int the Pay = sc.nextInt ();

// determine whether the amount is reasonable bet, wager amount not less than the prescribed casino, it can not be greater than in the hands of balance
the while (the Pay <500 || the Pay> Money) {
IF (the Pay <500) {
System.out.println ( "you bet less than 500, please re-bet bet amount not less than 500:");
}else {
System.out.println ( "You can not pay the money in his pocket already, please re-bet");
}
the Pay = sc.nextInt ();
}

. 7 // output
System.out.println (a + "\ t "+ B +" \ T "+ C);
System.out.println (" The dice roll results: "result +);

//. 8 determines whether the winning.
iF (guess.equals (result)) {
the System.out .println ( "Congratulations on winning to obtain" + pay + "dollars");
Money Money + = Pay;
} the else {
System.out.println ( "Keep up the next one will win");
Money = Money - Pay;
}
System.out.println ( "your balance is" Money +);
//. 9.Determining whether to continue playing the money
if (money <500) {
System.out.println ( "insufficient funds, Goodbye");
BREAK;
} the else {
System.out.println ( "Press Exit n, press any key to continue other \ n ************* ************************************************************ ");
String Again sc.next = ();
IF (" n-".equals (Again)) {
the System.out. println ( "little guy, next time to play this game");
BREAK;
}
}

}

System.out.println ( "goodbye *************************************** money, money again, goodbye ***** ******* ");
}
}

 

 

☞ operating results

 

Tuning ☞ direction:

Use exception catching illegal input processing

 

☞ anomaly occurred during:

Enter the non-declared variable type of input matching error occurs, a temporary solution only after restarting the program entered in accordance with legal way

 

Guess you like

Origin www.cnblogs.com/twuxian/p/11100322.html