Your TennisPlayer class should currently contain fields, accessors and mutators
ID: 3705710 • Letter: Y
Question
Your TennisPlayer class should currently contain fields, accessors and mutators for each field, a few constructors and a display method.
In this assignment, you will be adding a method and modifying the display method.
Create a method called calcWinPercentage() that returns a double representing the winning percentage of the player. (Winning perentage = wins/games.) The value returned will be between 0 (lost all games) and 1 (won all games). Since we are dividing here, we have to make sure we do not divide by 0 and make sure we are not performing integer division. If there are no games, return -1.
Modify displayPlayer() to also display winning percentage. Since winning percentage is a calculated value, it is not stored in the object (and there is no data field). Instead of displaying a field, the method calcWinPercentage() will be called. The value returned by the method will be multiplied by 100 for whole number form. Display this value to one digit after the decimal point. To display the percent sign with printf, use %%. If no games have been played, display “No games played” for winning percentage.
Explanation / Answer
Hi Dear,
Please find my implementation.
Please let me know in case of any issue.
Please DONT forgot to rate my answer. We are working hard for you Guys!!
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.