Which of the following is NOT an acceptable input validation technique for a player's choice in a Rock, Paper, Scissors game?1 pointUsing a try-except block to catch invalid inputsAsking the player to enter a number instead of a choiceProviding a list of valid choices and checking if the player's input is in that listIgnoring invalid inputs and continuing the game
Question
Which of the following is NOT an acceptable input validation technique for a player's choice in a Rock, Paper, Scissors game?1 pointUsing a try-except block to catch invalid inputsAsking the player to enter a number instead of a choiceProviding a list of valid choices and checking if the player's input is in that listIgnoring invalid inputs and continuing the game
Solution
The option that is NOT an acceptable input validation technique for a player's choice in a Rock, Paper, Scissors game is "Ignoring invalid inputs and continuing the game". This is because ignoring invalid inputs can lead to confusion and errors in the game. It's important to validate the player's input and provide feedback if the input is invalid, so the player can make a valid choice.
Similar Questions
How would using a try and except block help us validate user inputs if the input needsto be casted to a numeric data type, such as an int?
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 bet with a maximum amount of 100 is received?a.) // Track if input of bet is valid int betAmount = -1; // Assume invalid input of number until it proves to be correct while(!betAmount < 0) { try { System.out.print("Pass Line Bet : "); betAmount = input.nextInt(); playMultipleGames(number,betAmount); } catch(InputMismatchcatchion ex) { System.out.println("Not a valid bet. Please enter a number between 1-100 for your bet."); // Clear out input to remove \n input.nextLine(); } } System.out.println(); // Add blank line in output b.) // Track if input of bet is valid int betAmount = -1; // Assume invalid input of number until it proves to be correct while(!betAmount < 0) { try { System.out.print("Pass Line Bet : "); betAmount = input.nextInt(); if (betAmount > 100) playMultipleGames(number,betAmount); else System.out.println("Please enter a non-negative number for your bet."); } catch(InputMismatchcatchion ex) { System.out.println("Not a valid bet. Please enter a number between 1-100 for your bet."); // Clear out input to remove \n input.nextLine(); } } System.out.println(); // Add blank line in outputc.) // Track if input of bet is valid int betAmount = -1; // Assume invalid input of number until it proves to be correct while(!betAmount > 100) { try { System.out.print("Pass Line Bet : "); betAmount = input.nextInt(); } catch(InputMismatchcatchion ex) { System.out.println("Not a valid bet. Please enter a number between 1-100 for your bet."); // Clear out input to remove \n input.nextLine(); } } System.out.println(); // Add blank line in output d.) // Track if input of bet is valid int betAmount = -1; // Assume invalid input of number until it proves to be correct while(!betAmount <= 100) { try { System.out.print("Pass Line Bet : "); betAmount = input.nextInt(); if (betAmount <= 100) playMultipleGames(number,betAmount); else System.out.println("Please enter a non-negative number for your bet."); } catch(InputMismatchcatchion ex) { System.out.println("Not a valid bet. Please enter a number between 1-100 for your bet."); // Clear out input to remove \n input.nextLine(); } } System.out.println(); // Add blank line in output
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 bet with a maximum amount of 100 is received?a.) // Track if input of bet is valid int betAmount = -1; // Assume invalid input of number until it proves to be correct while(!betAmount > 100) { try { System.out.print("Pass Line Bet : "); betAmount = input.nextInt(); } catch(InputMismatchcatchion ex) { System.out.println("Not a valid bet. Please enter a number between 1-100 for your bet."); // Clear out input to remove \n input.nextLine(); } } System.out.println(); // Add blank line in output b.) // Track if input of bet is valid int betAmount = -1; // Assume invalid input of number until it proves to be correct while(!betAmount < 0) { try { System.out.print("Pass Line Bet : "); betAmount = input.nextInt(); playMultipleGames(number,betAmount); } catch(InputMismatchcatchion ex) { System.out.println("Not a valid bet. Please enter a number between 1-100 for your bet."); // Clear out input to remove \n input.nextLine(); } } System.out.println(); // Add blank line in output c.) // Track if input of bet is valid int betAmount = -1; // Assume invalid input of number until it proves to be correct while(!betAmount < 0) { try { System.out.print("Pass Line Bet : "); betAmount = input.nextInt(); if (betAmount > 100) playMultipleGames(number,betAmount); else System.out.println("Please enter a non-negative number for your bet."); } catch(InputMismatchcatchion ex) { System.out.println("Not a valid bet. Please enter a number between 1-100 for your bet."); // Clear out input to remove \n input.nextLine(); } } System.out.println(); // Add blank line in outputd.) // Track if input of bet is valid int betAmount = -1; // Assume invalid input of number until it proves to be correct while(!betAmount <= 100) { try { System.out.print("Pass Line Bet : "); betAmount = input.nextInt(); if (betAmount <= 100) playMultipleGames(number,betAmount); else System.out.println("Please enter a non-negative number for your bet."); } catch(InputMismatchcatchion ex) { System.out.println("Not a valid bet. Please enter a number between 1-100 for your bet."); // Clear out input to remove \n input.nextLine(); } } System.out.println(); // Add blank line in output
With the tic-tac-toe game, why was the while loop selected as the choice to check for valid player position inputs?a.)The while loop is the best for definite iteration.b.)A while loop runs faster than a for loop.c.)The while loop can be used to wait indefinitely for a player to input valid inputs.d.)A while loop won't create an infinite loop.
Question 10Which of the following is an example of validation?1 pointuse of the software provides the correct results as documentedensuring the system locks out an account after three failed log-in attemptssoftware is well-received by the usersoftware recognizes incorrect inputs
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.