Menu

[Solved] C Secure Math Solution Programming Exercise 55 Page Discusses One Possible Solution Follow Q37201359

→ C ⓘNot secure! math Solution for Programming Exercise 5.5 THIS PAGE DISCUSSES ONE POSSIBLE SOLUTION to the follow ng exerci→ C ⓘNot secure! math Solution for Programming Exercise 5.5 THIS PAGE DISCUSSES ONE POSSIBLE SOLUTION to the follow ng exercise frotn this onimelavatextbok complex program that in the previous exercise, your program will need the classes defined in Card java. Deck java. Hand java, and BlackjackHand java (This is the longest and most come up so far in the exercises) objects of type slackjackstand, one for the dealer and one for the user. The general object in the user wins, false if the dealer wins The program needs an object of class Deck and two Blackjack is to get a hand of cards whose value is as close to 21 as possible, without going over. The game goes like this Frs two cards are dealt into ceach playe’s hand If the dealer’s hand has a value of 21 (This is called a “Blackjack”) Note that the dealer wins on a tie, so if both pl at this pount, then the dealer wins. Otherwise, if the user has 21, then the user wins jack ) Note that the dealer wins on a tie, so if both players have Blackjack, then the dealer wins Now, if the game has not ended, the user gets a chance to add some cards to her hand In this phase, the user sees her own cards and sees one of the (In a casino, the dealer deals himself one card face up and one card face down All the user’s cards are dealt face means to add another card to her hand, or to “Stand”, which means to stop taking cards In this phase, the user sees her own cards and sees one of the dealers two cards down. All the user’s cards are dealt face up) The user makes a decision whether to “Hit, which case, the game is over and the user loses. If not, then the process continues. The user gets to If the user Hits, there is a possibility that the user will go over 21. In that case, the decide again whether to Hit or Stand If the user Stands, the game will end, but first the dea value of the dealer’s hand is less than or equal to can be determined: If the dealer has gone over 21, the user wins. Otherwise, if the dealer’s aler gets a chance to draw cards. The dealer only follows rules, without any choice The rule is that as long as the 16, the dealer Hits (that is, takes another card). The user should see all the dealer’s cards at this s total is greater than or equal to the users total, then the dealer wins. Otherwise, the user wins Two notes on programming At any point in the subroutine, as soon as you know who the winner is, you can say” to the main program. To avoid having an ov winner is, you can say “return true,” or “return false, to end the subroutine and return bles in your subroutine, remember that a function call such as usertHand.getolackjackvalue() can be used anywbere be used, including in an output statement or in the condition of an if statement main program that lets the user play several games of Blackjack To make things interestung, gsve the user 100 dollars, and let the user make If the user an amount equal to the bet to the user’s money End the program when the user wants to quit or when she runs out of money , is an applet that simulates the program you are supposed to write It would probably be morthwhile so p e to play it for a while to see how it works Lets start by designing user wants to quit. We could ask the user after each game whether she wants to until the user runs out of money or until the e But anstead of this, Ijust tell the user to enter a bet Show transcribed image text → C ⓘNot secure! math Solution for Programming Exercise 5.5 THIS PAGE DISCUSSES ONE POSSIBLE SOLUTION to the follow ng exercise frotn this onimelavatextbok complex program that in the previous exercise, your program will need the classes defined in Card java. Deck java. Hand java, and BlackjackHand java (This is the longest and most come up so far in the exercises) objects of type slackjackstand, one for the dealer and one for the user. The general object in the user wins, false if the dealer wins The program needs an object of class Deck and two Blackjack is to get a hand of cards whose value is as close to 21 as possible, without going over. The game goes like this Frs two cards are dealt into ceach playe’s hand If the dealer’s hand has a value of 21 (This is called a “Blackjack”) Note that the dealer wins on a tie, so if both pl at this pount, then the dealer wins. Otherwise, if the user has 21, then the user wins jack ) Note that the dealer wins on a tie, so if both players have Blackjack, then the dealer wins Now, if the game has not ended, the user gets a chance to add some cards to her hand In this phase, the user sees her own cards and sees one of the (In a casino, the dealer deals himself one card face up and one card face down All the user’s cards are dealt face means to add another card to her hand, or to “Stand”, which means to stop taking cards In this phase, the user sees her own cards and sees one of the dealers two cards down. All the user’s cards are dealt face up) The user makes a decision whether to “Hit, which case, the game is over and the user loses. If not, then the process continues. The user gets to If the user Hits, there is a possibility that the user will go over 21. In that case, the decide again whether to Hit or Stand If the user Stands, the game will end, but first the dea value of the dealer’s hand is less than or equal to can be determined: If the dealer has gone over 21, the user wins. Otherwise, if the dealer’s aler gets a chance to draw cards. The dealer only follows rules, without any choice The rule is that as long as the 16, the dealer Hits (that is, takes another card). The user should see all the dealer’s cards at this s total is greater than or equal to the users total, then the dealer wins. Otherwise, the user wins Two notes on programming At any point in the subroutine, as soon as you know who the winner is, you can say” to the main program. To avoid having an ov winner is, you can say “return true,” or “return false, to end the subroutine and return bles in your subroutine, remember that a function call such as usertHand.getolackjackvalue() can be used anywbere be used, including in an output statement or in the condition of an if statement main program that lets the user play several games of Blackjack To make things interestung, gsve the user 100 dollars, and let the user make If the user an amount equal to the bet to the user’s money End the program when the user wants to quit or when she runs out of money , is an applet that simulates the program you are supposed to write It would probably be morthwhile so p e to play it for a while to see how it works Lets start by designing user wants to quit. We could ask the user after each game whether she wants to until the user runs out of money or until the e But anstead of this, Ijust tell the user to enter a bet

Expert Answer


Answer to → C ⓘNot secure! math Solution for Programming Exercise 5.5 THIS PAGE DISCUSSES ONE POSSIBLE SOLUTION to the follow … . . .

OR


Leave a Reply

Your email address will not be published. Required fields are marked *