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

I can not figure out how to write these For example - what is the probability of

ID: 3621299 • Letter: I

Question

I can not figure out how to write these

For example - what is the probability of throwing two die and getting a total of 2. The
answer is that there is a 1/6 chance of throwing a 1 on the first die and an identical
probability for the second die, therefore the total probability is 1/36. You can
approximate this for yourself by throwing the two die 20000 times and seeing how
many times two comes up. When you realize how long this is going to take, you get
the clever idea that it would be much easier to write a program to simulate the die
throw and compute the probabilities that way. But why stop with checking only for the
die total of two - so you decide to write a program that will ask the user what die total
they wish to test for and then generate 20000 die throws. Print the running probability
after each 1000 throws.
Example Run
What Die total do you wish to test for (2 - 12): 7
Computed Probability for Die throw = 7
Die throws Probability
1000 0.16000
2000 0.16950
3000 0.16467
4000 0.16850
...
18000 0.16611
19000 0.16695
20000 0.16685


Estimating PI

PI can be approximated by summing up the following series:
PI = 4 * (1 – (1/3) + (1/5) – (1/7) + (1/9) – (1/11) + (1/13) - … )
Write a program that will compute the approximation for 30000 terms. To monitor the
progress of your simulation print out the PI approximation every 1000 terms.
FYI - the approximation should begin to approach 3.14159 .

Explanation / Answer

please rate - thanks

CRAMSTER rule is 1 question per post

question 2

#include <iostream>
using namespace std;
int main()
{double pi=0;
int i=0,den=1,flip=1;
cout<<"try pi ";
do
       {pi=pi+(4./den)*flip;
       //cout<<i<<" "<<pi<<endl;
       flip=0-flip; //0-1==-1     0--1=1
       den+=2;
       i++;
       if(i%1000==0)
           cout<<i<<" "<<pi<<endl;
       }while(i<30000);
system("pause");    
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