Tennis game

closed account (D1b4z8AR)
hi I am new to c++ and having problems programming a certain code, any sort of help would be greatly appreciated.

Write a C++ program using functions to simulate a tennis singles match. If you follow the game of tennis you are aware of the scoring system, 15, 30, 40, game. Then, of course there is 40-40 or deuce, with one player having to get 2 points ahead to win a game. Thus, to win a game a player needs to score 4 points, but also to be 2 points ahead. For example, the first game is represented by ABAABBAA and player A has won it. It went to deuce then player A won two points. The second game was represented byBABAABABBB.ThisgamewaswonbyplayerB. Again,itwenttodeuce,playerAwentaheadby1but player B caught up. Player B then won the last 2 points. After all that, the score would be 1 game all.
Assume that the two players in a tennis match are each assigned a skill level from 0 to 10. The higher the skill level, the more likely that player is to win a particular point. For example, if player 1 and player 2 have identical skill levels, say 6.5 and 6.5, each is equally likely to win a given point. However, if player 1 has a skill level of 6.5 and player 2 has a skill level of 3.25, then player 1 is twice as likely to win a given point. For example, in Python (in Ping Pong):
The function listed above simulates a single point in a ping pong match and returns the winning player number (1 or 2). We will adjust it to simulate it for a single point in tennis (TennisPoint). The function should have two real numbers as input between 0 and 10 indicating a play level for each player (10 is the best). Other functions to use in the program:
• TennisSet()-Simulates a complete game of tennis by calling TennisPoint.
• TennisMatch()-Simulates a complete game of tennis by calling TennisSet.
Let the user input the players by number (Player 1, etc.) as well as their skill levels. The program should output players, each point, set, and games won, and the overall match winner. Output should be user friendly.

I am new to c++ and having problems programming a certain code
Hi underdog, what problems are you having? What have you tried so far?
I really don't see why you need us to show you how to implement it, there should be python code that shows how to do it, which should be easy to translate. If the python code isn't complete you should still try to convert that to C++ and testing it before continuing. If you have any problems, tell us, and ideally show the current state of your code, or the section that is causing problems.

Also read the beginners sticky:
http://www.cplusplus.com/forum/beginner/1/

and use code tags before posting code:
http://www.cplusplus.com/articles/jEywvCM9/
Last edited on
undrdog wrote:
have a blessed day

Keep that kind of filth to yourself, buddy.
@undrdog, all you did was ask people to do your homework for you.
undrdog wrote:
And I’m not your buddy

Well duh, buddy. You really are stupid!
Nobody is appreciating your snarkyness undrdog. I was gonna ask you if you were high before posting because you seem to making an excuse for why you can't do your homework with personal reasons like we were your teachers to the response of what have you done at all, but I decided not to say that. When it comes to programming you should keep your personal life to yourself because this place isn't your personal blog (I didn't mind the complement, but you probably wouldn't have gotten a bad response if you just did what I asked for).

You need to show us the current state of your code if you want anyone to give you any hints. We asked you twice but you expect us to write everything for you. The hints are in your assignment, what don't you understand?

(ouch it seems like an admin got undrdog, or dutch reported the questions and deleted the messages using his post count, but you did cross the line with that insult, posting homework on the general section, and posting only the question to your homework without adding anything to it...)

If you are reading this, just remember that you should always put your problems onto yourself and never blame other people for your inabilities especially in scenarios with "should've, would've, could've". When you blamed yourself for skipping a year of school, you are blaming your problem on an external reason "nobody told you" which is your excuse to be unable to do this problem, but the longer you tell yourself that, the less you will grow as a programmer. Programming is all about independence, for some people, it is true that you could learn everything a semester teaches you in a week, you just need to be determined and just do it, and get used to doing stuff without anyone's help, that is until you reach a nasty gotcha, then ask, and you should always doubt your assumptions and double check with the docs/tests when you can.
Last edited on
Topic archived. No new replies allowed.