Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started