Within the tutorial casino craps game pseudocode, where should you place the pseudocode that performs the task of "Get if the player won or lost" and how (in pseudocode) should this task be implemented?a.)In Loop until Games Played = Times to Play, with pseudocodeLoop until Games Played = Times to Play...If the player won...Set "Get if the player won or lost" to wonElse if player lost...Set "Get if the player won or lost" to lostb.)In method play, with pseudocodemethod play()...return if the player won or lostc.)In Loop until Games Played = Times to Play, with pseudocodeLoop until Games Played = Times to Play...If the player won...Else if player lost...Set "Get if the player won or lost" to won or lostd.)In method play, with pseudocodemethod play()...set a local variable to won or lost
Question
Within the tutorial casino craps game pseudocode, where should you place the pseudocode that performs the task of "Get if the player won or lost" and how (in pseudocode) should this task be implemented?a.)In Loop until Games Played = Times to Play, with pseudocodeLoop until Games Played = Times to Play...If the player won...Set "Get if the player won or lost" to wonElse if player lost...Set "Get if the player won or lost" to lostb.)In method play, with pseudocodemethod play()...return if the player won or lostc.)In Loop until Games Played = Times to Play, with pseudocodeLoop until Games Played = Times to Play...If the player won...Else if player lost...Set "Get if the player won or lost" to won or lostd.)In method play, with pseudocodemethod play()...set a local variable to won or lost
Solution
The pseudocode that performs the task of "Get if the player won or lost" should be placed in the method play. This is because the determination of whether a player has won or lost is part of the game play process. The pseudocode should be implemented as follows:
method play() ... If player's score is 7 or 11 return "won" Else if player's score is 2, 3, or 12 return "lost" Else Loop until player's score is 7 or player's score equals the point If player's score is 7 return "lost" Else if player's score equals the point return "won"
This pseudocode first checks if the player's score is 7 or 11, in which case the player wins. If the player's score is 2, 3, or 12, the player loses. If the player's score is any other number, that number becomes the point. The game then continues until the player rolls a 7, in which case they lose, or they roll the point again, in which case they win.
Similar Questions
For the craps game in the tutorial, the client may want to enter a cash amount to bet for each game. If they bet (e.g., $5) and win, they receive two times their bet ($10); if they lose, the money they bet (e.g., $5) goes to the casino.If you need to add the core logic to allow a player to bet in this way, what pseudocode accurately represents this task?a.)# Ask the player how much to bet#Play the game# If the player won the first game add double the bet to the total won# else the player lost so subtract the bet from the total wonb.)# Ask the player how much to bet per game#Play the game# If the player won add the bet to the total won# else the player lost so subtract the bet from the total wonc.)# Ask the player how much to bet#Play the game# If the player won add double the bet to the total won# If the player lost subtract double the bet from the total wond.)# Ask the player how much to bet per game# Play the game# If the player won the game add double the bet to the total won# else the player lost so subtract the bet from the total won
For the casino craps game in the tutorial, why would you want to start with an example where a winner or loser is selected on the first roll?a.)The game must end with a winner or loser on the first roll.b.)It's best to start by breaking down the problem into a simpler one.c.)The game must start with a winner or loser on the first roll.d.)It's best to start by solving the most the complex part of the problem first.
What is Pseudo-code?
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
Pseudocode: Pseudocode is a plain language description of the steps in an algorithm. The following pseudocode algorithm prompts the user to enter two integers, inputs them from the user at the keyboard, adds them, then stores and displays their sum: Prompt the user to enter the first integer Input the first integer Prompt the user to enter the second integer Input the second integer Add first integer and second integer, store their sum Display the numbers and their sum 5. Write a pseudocode algorithm for washing a car.
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.