Answered step by step
Verified Expert Solution
Question
1 Approved Answer
program with C A tennis game between two players has the following rules: 1. 2. A point can be won by either player A game
program with C
A tennis game between two players has the following rules: 1. 2. A point can be won by either player A game is won when one player wins at least 4 points and leads the opponent by at least two points You are to simulate the playing of a game of tennis as follows: . The players are labelled 'A' and 'B'. . The user is asked to enter the probability (in whole number https://www.i tennis-balls-1 percent) that A will win any given point. Each point won by player A should be indicated by printing the letter A. If player A loses the point, then point B wins and the letter B should be printed Once there is a winner, display the final score and declare a winner. To decide who gets the point you are to use a random number generator. Please refer to the code random. cpp which you downloaded at the same time as this handout to see how to use the random number generator in C++ for this question. Your program should: 1. 2. Display a welcome message Prompt the user for and read the probability that player A wins the point (an integer between 1 and 100) 3. As long as there is no winner a. Generate a random number between 1 and 100 b. If it is less than or equal to the probability entered by the user, point goes to player A, otherwise the point goes to player B c. Display the winner of this point d. Check if there is a winner. 4. Display the total scores and the winner of the game in a closing message Following are some sample screen shots to illustrate the expected behavior of your program. User input at the keyboard is marked with a red circle Note 1: Assume a perfect user who will always enter a positive integer between 1 and 100. Note2: Your program must display the same information but the output can be formatted differently. Sinulation of a gane of tennis hat is x chance that player 'A' vins a point? cEnter a nunber between 8 and 188)55 BBABB The final score is 1 (A4 (B >The winner is playerB Figure 8- Sample output screen 1 for Question 2Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started