Python Programming: An Introduction to Computer Science, 3rd Ed.
Python Programming: An Introduction to Computer Science, 3rd Ed.
3rd Edition
ISBN: 9781590282755
Author: John Zelle
Publisher: Franklin, Beedle & Associates
bartleby

Concept explainers

bartleby

Videos

Question
Book Icon
Chapter 9, Problem 8PE
Program Plan Intro

Blackjack game

Program Plan:

  • Import the header file.
  • Define the main method.
    • Call the “printIntro ()” method.
    • Get the input from the user.
    • Call the “simNHands ()” method and store it in a variable.
    • Call the “printSummary ()” method.
  • Define the “printIntro ()” method.
    • Display the messages.
  • Define the “simNHands ()” method.
    • Set the values.
    • Iterate “i” until it reaches “n” value
      • Check the result of “simOneHand ()” is false
        • Increment the “busts” value
          • Return the “busts” value.
  • Definition of “simOneHand ()” method
    • Call the simOneCard ()” methods and store it in a different variables.
    • Calculate “hand” value
    • Check the “hand” value is less than 17
      • Check  the result of “hasAce (x)” is true
        • Check the “hand “value is less than or equal to 10
          • Set the “x” value as 11.
          • Calculate the “hand” value
        • Otherwise, set the “x” value as 1.
      • Check the result of “hasAce (y)” is true
        • Check the “hand “value is less than or equal to 10
          • Set the “y” value as 11.
          • Calculate the “hand” value
        • Otherwise, set the “y” value as 1.
      • Call the method and store it in a variable
      • Calculate the “hand” value
      • Check “hand” value is greater than 21
        • Return false
      • Otherwise, return true
  • Define the “simOneCard ()” method
    • Call the method with the arguments
    • Check “x” is equal to 11 or 12 or 13
      • Set the “x” as 10
      • Return “x”
            • Otherwise, return “x” value
  • Define the “hasAce ()” method
    • Check “x” is equal to 1
      • Return true
            • Otherwise, return false.
  • Define the “printSummary ()” method
    • Display the output.
  • Call the main method.

Blurred answer
Students have asked these similar questions
Othello is played as follows: Each Othello piece is white on one side and black on the other. When a piece is surrounded by its opponents on both the left and right sides, or both the top and bottom, it is said to be captured and its color is flipped. On your turn, you must capture at least one of your opponent's pieces. The game ends when either user has no more valid moves. The win is assigned to the person with the most pieces. Implement the object-oriented design for Othello.
BLACKJACK DO not use jquery strictly java script Black Jack is a simple card game that is also often called 21. The point of the game is to get a value as close to 21 without going over. A player that obtains the score of 21 with only 2 cards is said to have a Black Jack.   Rules of the game: There are 2 types of participants in a game of Black Jack, the dealer and the players. The players play against the dealer and not against each other. In order to win, the player must have a hand value superior to that of the dealer’s. The game starts with each player receiving 2 cards, the dealer receiving 2 cards. Each player has the option to add an additional cards (1 by 1) to his hand (Draw) or to stay with the cards he currently has (Hold). If at any point, the player’s total exceeds 21, he automatically loses the hand (Bust). When all players complete this process, the dealer gets to complete his hand. As long as the dealer’s point total is 16 or less, he must draw a new card. As soon as…
Description: Raghu and Sayan both like to eat (a lot) but since they are also looking after their health, they can only eat a limited amount of calories per day. So when Kuldeep invites them to a party, both Raghu and Sayan decide to play a game. The game is simple, both Raghu and Sayan will eat the dishes served at the party till they are full, and the one who eats maximum number of distinct dishes is the winner. However, both of them can only eat a dishes if they can finish it completely i.e. if Raghu can eat only 50 kCal in a day and has already eaten dishes worth 40 kCal, then he can't eat a dish with calorie value greater than 10 kCal. Given that all the dishes served at the party are infinite in number, (Kuldeep doesn't want any of his friends to miss on any dish) represented by their calorie value(in kCal) and the amount of kCal Raghu and Sayan can eat in a day, your job is to find out who'll win, in case of a tie print "Tie" (quotes for clarity). Input: First line contains…
Knowledge Booster
Background pattern image
Computer Science
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
SEE MORE QUESTIONS
Recommended textbooks for you
Text book image
C++ for Engineers and Scientists
Computer Science
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Course Technology Ptr
Text book image
EBK JAVA PROGRAMMING
Computer Science
ISBN:9781337671385
Author:FARRELL
Publisher:CENGAGE LEARNING - CONSIGNMENT
Text book image
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole
Control Structure in Data Structure - Data Structures - Computer Science Class 12; Author: Ekeeda;https://www.youtube.com/watch?v=9FTw2pXLhv4;License: Standard YouTube License, CC-BY