Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

n the main method Ask the user for the name of a sports player Ask the user for

ID: 3718553 • Letter: N

Question

n the main method

Ask the user for the name of a sports player

Ask the user for the number of years the sports player has played competitive sport. Use this value as the size of a double array.

Ask the user for the year the sport player began playing competitive sport

In a for loop, ask the user to enter the number of wins and losses starting from the first year of play and store the win percentage (wins/(wins+losses)) value in the array. The element at index 0 will store the win percentage for the player’s first year.

Call the method printWinPercentage with the player’s name, the first year of play and the array

In the printWinPercentage method:

There should be three parameters: a String for the player’s name, int for the first year of play, and a double array

Display the player’s name

Display the year and the win percentage for each year with 1 number after the decimal.

Explanation / Answer

Here is the sample output:

Enter the name of player: John
Enter the number of years played: 3
Enter the first year of competitive start: 1900
Enter number of wins in year 1900: 5
Enter number of losses in year 1900: 3
Enter number of wins in year 1901: 6
Enter number of losses in year 1901: 1
Enter number of wins in year 1902: 9
Enter number of losses in year 1902: 3
Player Name : John
Win percentage in year 1900:0.6
Win percentage in year 1901:0.9
Win percentage in year 1902:0.8