Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Need help with the C++ code!!! Questions #2. Tennis Game Simulation (8 pts). A tennis game between two players has the following rules: 1. 2.

image text in transcribedimage text in transcribedimage text in transcribed

Need 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. Display the winner of this point Check if there is a winner a. b. c. d. 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. C:Windowslsystem321cmd.exe Sinulation of a game of tennis hat is % chance that player 'A' wins a point? Enter a number between 0 and 100):155 BABB [The final score is 1 A -4 B) The winner is player B

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases 11th British National Conference On Databases Bncod 11 Keele Uk July 7 9 1993 Proceedings Lncs 696

Authors: Michael F. Worboys ,Anna F. Grundy

1993rd Edition

3540569219, 978-3540569213

More Books

Students also viewed these Databases questions

Question

6. Identify seven types of hidden histories.

Answered: 1 week ago

Question

What is human nature?

Answered: 1 week ago