Absolute C++, Student Value Edition, 6/e
Absolute C++, Student Value Edition, 6/e
6th Edition
ISBN: 9780133970982
Author: SAVITCH
Publisher: Pearson Education
bartleby

Videos

Textbook Question
Book Icon
Chapter 4, Problem 12PP

In the land of Puzzlevania, Aaron, Bob, and Charlie had an argument over which one of them was the greatest puzzle-solver of all time. To end the argument once and for all, they agreed on a duel to the death. Aaron was a poor shot and only hit his target with a probability of 1/3. Bob was a bit better and hit his target with a probability of 1/2. Charlie was an expert marksman and never missed. A hit means a kill and the person hit drops out of the duel. To compensate for the inequities in their marksmanship skills, the three decided that they would fire in turns, starting with Aaron, followed by Bob, and then by Charlie. The cycle would repeat until there was one man standing. That man would be remembered for all time as the Greatest Puzzle-Solver of All Time. An obvious and reasonable strategy is for each man to shoot at the most accurate shooter still alive, on the grounds that this shooter is the deadliest and has the best chance of hitting back.

Write a program to simulate the duel using this strategy. Your program should use random numbers and the probabilities given in the problem to determine whether a shooter hits his target. You will likely want to create multiple subroutines and functions to complete the problem. Once you can simulate a duel, add a loop to your program that simulates 10,000 duels. Count the number of times that each contestant wins and print the probability of winning for each contestant (e.g., for Aaron your program might output "Aaron won 3595/10,000 duels or 35.95%").

An alternate strategy is for Aaron to intentionally miss on his first shot. Modify the program to accommodate this new strategy and output the probability of winning for each contestant. What strategy is better for Aaron, to intentionally miss on the first shot or to try and hit the best shooter?

Blurred answer
Students have asked these similar questions
The bean machine, also known as a quincunx or the Galton box, is a device for statistics experiments named after English scientist Sir Francis Galton. It consists of an upright board with evenly spaced nails (or pegs) in a triangular pattern, as shown in Figure 10.15. Balls are dropped from the opening of the board. Every time a ball hits a nail, it has a 50% chance of falling to the left or to the right. The piles of balls are accumulated in the slots at the bottom of the board. Write a program that simulates the bean machine. Your program shouldprompt the user to enter the number of the balls and the number of the slots in the machine. Simulate the falling of each ball by printing its path. For example, the path for the ball in Figure 10.15b is LLRRLLR and the path for the ball in Figure 10.15c is RLRRLRR. Display the final buildup of the balls in the slots in a histogram.
Mastermind is a code-breaking game for two players. In the original real-world game, one player A selects 4 pegs out of 6 colors and puts them in a certain fixed order; multiples of colors are possible (for example, red-green red-green). His opponent B does not know the colors or order but has to find out the secret code. To do so, B makes a series of guesses, each evaluated by the first player. A guess consists of an ordered set of colors which B believes is the code. The first player A evaluates the guess and feeds back to B how many positions and colors are correct. A position is correct ("black") if the guess and the secret code have the same color. Additional colors are correct ("white"), if they are in the guess and the code, but not at the same location. For example1 2 3 4secret: red-green red greenguess: red blue green purpleresults in one correct position ("black = 1") for the red peg at position one and one additional correct color ("white=1") for the green peg in the guess.…
Mastermind is a code-breaking game for two players. In the original real-world game, one player A selects 4 pegs out of 6 colors and puts them in a certain fixed order; multiples of colors are possible (for example, red-green red-green). His opponent B does not know the colors or order but has to find out the secret code. To do so, B makes a series of guesses, each evaluated by the first player. A guess consists of an ordered set of colors which B believes is the code. The first player A evaluates the guess and feeds back to B how many positions and colors are correct. A position is correct ("black") if the guess and the secret code have the same color. Additional colors are correct ("white"), if they are in the guess and the code, but not at the same location. For example1 2 3 4secret: red-green red greenguess: red blue green purpleresults in one correct position ("black = 1") for the red peg at position one and one additional correct color ("white=1") for the green peg in the guess.…

Additional Engineering Textbook Solutions

Find more solutions based on key concepts
Which of the following expressions return true? After writing your answers on paper, open the Code Pad in Bl...

Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)

Give an example of a data constraint.

Database Concepts (8th Edition)

What will the following program display? public class Checkpoint { public static void main (String [] args) { i...

Starting Out with Java: From Control Structures through Objects (7th Edition) (What's New in Computer Science)

Describe a method that can be used to gather a piece of data such as the users age.

Web Development and Design Foundations with HTML5 (9th Edition) (What's New in Computer Science)

Use a comment to state that a program performs a sample payroll calculation.

Java How to Program, Early Objects (11th Edition) (Deitel: How to Program)

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
Operations Research : Applications and Algorithms
Computer Science
ISBN:9780534380588
Author:Wayne L. Winston
Publisher:Brooks Cole
6 Stages of UI Design; Author: DesignerUp;https://www.youtube.com/watch?v=_6Tl2_eM0DE;License: Standard Youtube License