- #1
magnifik
- 360
- 0
can anyone help me understand the following project specs? it is supposed to be relatively simply to code, but i can't even figure out what exactly I'm supposed to do.
there are 1000000 people choosing A or B. the process repeats 1000 times. 520000 chose A while 480000 chose B. but there was a 15% error in which B was mistaken for A or A was mistaken for B. is the 15% rate enough to make the results invalid? find the acceptable error rate.
this is what i have so far. I'm not sure how to take into account the error or number of people who actually choose A or B.
there are 1000000 people choosing A or B. the process repeats 1000 times. 520000 chose A while 480000 chose B. but there was a 15% error in which B was mistaken for A or A was mistaken for B. is the 15% rate enough to make the results invalid? find the acceptable error rate.
this is what i have so far. I'm not sure how to take into account the error or number of people who actually choose A or B.
Code:
int main(){
int A = 0;
int B = 0;
int aWins = 0;
srand(time(0));
for (int j = 0; j < 1000; j++){
for (int i = 0; i < 1000000; i++){
if ((rand()%2) == 0)
B++;
else
A++;
}
if (A > B)
aWins++;
}
cout << aWins << endl;
cout << (double)(aWins*100)/1000<< endl;
}