Question: For the craps game in the tutorial, if code were implemented to input a bet for a player, what code segment would ensure that a
For the craps game in the tutorial, if code were implemented to input a bet for a player, what code segment would ensure that a nonnegative number bet is received?
a
Track if input of bet is valid
int betAmount ;
Assume invalid input of number until it proves to be correct
whilebetAmount
try
System.out.printPass Line Bet : ;
betAmount input.nextInt;
catchInputMismatchcatchion ex
System.out.printlnNot a valid bet. Please enter a number for your bet.";
Clear out input to remove
input.nextLine;
System.out.println; Add blank line in output
b
Track if input of bet is valid
int betAmount ;
Assume invalid input of number until it proves to be correct
whilebetAmount
try
System.out.printPass Line Bet : ;
betAmount input.nextInt;
playMultipleGamesnumberbetAmount;
catchInputMismatchcatchion ex
System.out.printlnNot a valid bet. Please enter a number for your bet.";
Clear out input to remove
input.nextLine;
System.out.println; Add blank line in output
c
Track if input of bet is valid
int betAmount ;
Assume invalid input of number until it proves to be correct
whilebetAmount
try
System.out.printPass Line Bet : ;
betAmount input.nextInt;
if betAmount
playMultipleGamesnumberbetAmount;
else
System.out.printlnPlease enter a nonnegative number for your bet.";
catchInputMismatchcatchion ex
System.out.printlnNot a valid bet. Please enter a number for your bet.";
Clear out input to remove
input.nextLine;
System.out.println; Add blank line in output
d
Track if input of bet is valid
int betAmount ;
Assume invalid input of number until it proves to be correct
whilebetAmount
try
System.out.printPass Line Bet : ;
betAmount input.nextInt;
if betAmount
playMultipleGamesnumberbetAmount;
else
System.out.printlnPlease enter a nonnegative number for your bet.";
catchInputMismatchcatchion ex
System.out.printlnNot a valid bet. Please enter a number for your bet.";
Clear out input to remove
input.nextLine;
System.out.println; Add blank line in output
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
