In straight-11 ping-pong, the first player to reach 11 points wins; the
player need not be ahead by 2. Suppose that when Ada plays Blaise, Ada has
a .56 probability of winning any given point. We want to write a program
that simulates a game between Ada and Blaise, with the printout displaying
a running score of the game. For example a typical output might be:

  Game 1 

Ada Blaise

1 0
2 0
2 1
. .
. .
. .
11 8

          Ada won 11 to 8 

Write a program in which Ada and Blaise play three games of straight-11
ping-pong. Print the results of each game as well as the overall winner of
the three matches

i am having truble being able to set up a game like this if i could get an example

Alright firstly, this forumn the people are not going to do something for you if you aren't prepared to do something yourself... I will however try to help you in getting started...

First place... find what is expected of your program... is there any user input? or is it all automatic? (HINT: "Ada has a .56 probability of winning any given point.")

how do you know the program has completed its purpose? (HINT: "the first player to reach 11 points wins")

Now tell me what you understand under the above statements... attempt to write a bit of code... and I'll help you further

well i did not thnk what had so far was useful and i really am not looking some to d ths for here is what i have

Code blocks are created by indenting at least 4 spaces
... and can span multiple lines

include <iostream>

include <cstdlib>

using std::cout;
using std::rand;

int main()
{
int ada
int bliase
ada=0
blaise= 0
for( )// i know i need some type of function here but not sure what
if
ada= ada +1;
else
blaise = blaise+1;

return 0;
}
Emphasized Text Here
i am really not sue how to add in the .56 probablity thing

i forgot to add the end for when it equals 11

Code blocks are created by indenting at least 4 spaces
... and can span multiple lines
for (ada =10; ada>10;blaise =10; bliase>10;)
 {
for( )// i know i need some type of function here but not sure what
if
ada= ada +1;
else
blaise = blaise+1;
if (ada==11; blaise==11)
{
  cout << "game 1";
  break;

There is probably a mathematical way to account for the 56% probability, but you could also hard code it. To hard code it you could create and array of 100 ints all assigned to 0s. Then place 44 randomly placed 1s in the array. Then for each turn, get a random int called index from 0-99. If the value of the element of the game array at index is 0 Ada wins the point. Otherwise Blaise wins the point. If you want, reassign the random int array with each new game, but that probably isn't necessary since each play is random to begin with.

i am really not sue how to add in the .56 probablity thing

here's one way:
considering that you know how to use rand()
you could randomize a value from 0 to 99 and if it lands between 0-55 player ada wins else if it's 56 - 99 the other player wins

Comments
agree with the function suggested 100%

As Zeroliken said rand() is your best bet...

I assume you are being tested on the random function because that is really all that makes sense to me...

If you were supposed to work with input that was another situation... either way...

"rand() % 10 + 1" gives you a value between 1 and 10...

the reason for the "+ 1" is that rand() starts at 0... now using what zeroliken said above... look if you can complete the function in your for (I would use a while btw)

This article has been dead for over six months. Start a new discussion instead.