Question: c++ language Objective: practice writing call-by-reference function and using random numbers In the land of PuzzleVania, Aaron, Bob, and Charlie had an argument over which

c++ language

Objective: practice writing call-by-reference function and using random numbers

In the land of PuzzleVania, Aaron, Bob, and Charlie had an argument over which one of them was the greatest puzzler of all time. To end the argument once and for all, they agreed on a duel to the death. Aaron is a poor shooter and only hits his target with a probability of 1/3, Bob is a bit better and hits his target with a probability of . Charlie is an expert marksman and never misses. A hit means a kill and the person hit drops out of the duel.

To compensate for the inequities in their marksmanship skills, it is decided that the contestants would fire in turns starting with Aaron, followed by Bob, and then by Charlie. The cycle would repeat until thre was one man standing the greatest puzzler of all time.

1. Write a function to simulate a single shot. It should use the following declaration:

void shoot(bool& targetAlive, double accuracy);

This would simulate someone shooting at targetAlive with the given accuracy by generating a random number between 0 and 1. If the random number is less than accuracy, then the target is hit and targetAlive should be set to false.

2. Strategies:

a. shoot at the most accurate shooter still alive on the grounds

b. shoot at random target still alive on the grounds

Write a second function that use the shoot function to simulate the entire fuel using the above mentioned strategy respectively, it should loop until only one contestant is left. The function will return a variable that indicates who won the duel.

In your main function, test run your functions and output the probability that each contestant will win with the above mentioned strategy.

The location to save your file \\fs1\100; you will see a folder with your student number, copy your project and paste it in the folder with your number.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!