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 method play, with pseudocodemethod play()...set a local variable to won or lostb.)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 lostc.)In method play, with pseudocodemethod play()...return if the player won or lostd.)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 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 method play, with pseudocodemethod play()...set a local variable to won or lostb.)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 lostc.)In method play, with pseudocodemethod play()...return if the player won or lostd.)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 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 play() method is where the game is actually played and the outcome (win or loss) is determined.
Here is how this task can be implemented in pseudocode:
method play()
... // game logic here
if player won
return "won"
else if player lost
return "lost"
end if
end method
This pseudocode first executes the game logic. If the player wins, the method returns "won". If the player loses, the method returns "lost". This way, the outcome of the game is always returned when the play() method is called.
So, the correct answer is c.) In method play, with pseudocode:
method play()
... // game logic here
return if the player won or lost
end method
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.
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
What is Pseudo-code?
In your own words, what is Pseudo-Code?
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.