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

The new hot game in casino\'s is the Parker Push! In this game there is an initi

ID: 3792130 • Letter: T

Question

The new hot game in casino's is the Parker Push! In this game there is an initial point value. This point value is then repeatedly either decreased by one or double, each with a probability of 50%. If the value goes over 20, it is reset to the initial point value and the game starts over again. The game ends when either a one or eleven are reached. Build a program that reads in an initial value, then plays 1,000,000 games of Parker Push. Tell how many games end in 1s and how many end in 11s. You may assume the initial value is positive and less than 20. Example 1 (user input is underlined): What initial value? 3 1s = 623141 11s = 376859 Example 2 (user input is underlined): What initial value? 4 1s = 510069 11s = 489931 Example 3 (user input is underlined): What initial value? 4 1s = 510445 11s = 489555

Explanation / Answer

the only trick here to achieve a probablity of 50% in the game . there can be many method for it . I am using that of random interger and taking it mod by 2. we know that random no has 50% of being even and 50% probality of being odd. so our solution will be 0 or 1. if 0 then double the number if 1 then dec by 1.

#include <ctime>
#include <iostream>
#include <string>

using namespace std;

// Functions
int main();
void Menu();
int PlayGame();
int IV=0;
int main()
{
// Seed the random number generator so we get actually random results!
srand(static_cast<unsigned int>(time(NULL)));

Menu();

return 0;
}


void Menu()
{
cout<<"what is the intial value?";
cin>>IV;
long int> long int eleven=0,ans;
for(int i=0;i<1000000;i++){
ans=PlayGame();

if(ans==1){
ones++
}
else{
eleven++;
}

}
cout<<"1s="<<ones<<" ";
cout<<"11S="<<eleven<<" ";


}

void PlayGame()
{
int num=IV;
  

while (num!=1||num!=11)
{
int randomNumber = rand();

if(randomnumber%2==0){
num=2*num;
}
else{
num--;
}
}

if(num==1){
return 1
}
else{
return 0;
}
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote