Answered step by step
Verified Expert Solution
Question
1 Approved Answer
HELP WITH THE C++ CODE!!!!! Questions #2: Tennis Game Simulation (8 pts). A tennis game between two players has the following rules: 1. 2. A
HELP WITH THE C++ CODE!!!!!
Questions #2: Tennis Game Simulation (8 pts). 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 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: Display a welcome message. Prompt the user for and read the probability that player A wins the point (an integer between 1 and 100) As long as there is no winner. 1. 2. 3. Generate a random number between 1 and 100. 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. a. 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. CWindowslsystem32)cmd.exe Simulation of a gane of tennis Nhat is % chance that player A, wins a point? Enter a number between 0 and 100) : 55 BBA BB The final score is 1 A -4 B) -The winner is player BStep 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