Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I am in an introductory c++ class. Please use the iostream library. Adam, Bob, a

ID: 3654312 • Letter: I

Question

I am in an introductory c++ class. Please use the iostream library. Adam, Bob, and Charlie agreed on a duel to the death (using paintball guns). Adam was a poor shot and only hit his target with a probability of 1/3. Bob hit his target with a probability of 1/2. Charlie never missed. A hit means a "kill" and the person hit drops out of the duel. They decided to fire in turns, staring with Adam, followed by Bob, and then Charlie. The cycle would repeat until one man was standing. An obvious and reasonably strategy is for each man to shoot at the most accurate opponent still alive. Write a program to simulate the duel and this strategy. Your program should use this pseudo random number function (Xn+1 =(a*Xn)+c) where a = 22695477, c = 1, and Xn is a single unsigned integer parameter and the probabilities given in the problem to determine whether a shooter hits his target. Once you can simulate a single duel, add an outer loop that simulates 10,000 duels. Count the number of times that each contestant wins and display his winning percentage Hint: Use the % operator to convert the pseudo-random numbers to a hit or miss

Explanation / Answer

//PSEUDO-RAND number still broken. #include #include using namespace std; int findprey(int , const bool[]); int hit(int player,const double prob[],int xn[]);//need to check this int main(){ const string names[3]={"Adam","Bob","Charlie"}; const double prob[3]={1/3,1/2,1/1}; bool alive[3]; int count,target; int Xn[3]={-1,-1,-1}; int winCounter[3]={0}; int games=0, NumberofGames; coutNumberofGames; for(int z=1;z