Class name: Basketball
Method name: MVP
Parameters: String[], int[], int[]
Returns: String
Implement a class Basketball, which has a method MVP.
Method signature: String MVP(String[] Names, int[] Points, int[] Assists) (be
sure your method is declared public)
*Names, Points, and Assists all have the same number of elements, between 1 and
10, inclusive
*Names is an Array of Strings which are player names
*Points is a Array of ints. Each element in the array represents the number of
points scored
by the player in the corresponding index of the Names array.
*Assists is an Array of ints. Each element in the array represents the number
of assists made
by the player in the corresponding index of the Names array.
Each element in each Array corresponds with the elements of the same index in
the other Arrays.
If Names[1] = "Joe", then Joe's points are Points[1] and assists are Assists[1];
The elements in Names are Strings of length 1 - 50, inclusive
The elements of Points and Assists are Integers between 0 and 100, inclusive.
You will calculate who the MVP (Most Valuable Player) is for the game in the
following way:
If any player has 20 or more points, the MVP is the player with 20 or more
points who has the highest total of points and assists (of all the players with
20 or more points).
If no player has 20 or more points, then the MVP is the player with the highest
total of points and assists.
Return the name of the player who is the MVP.
If more than one player has the highest total (Given the rules from above),
return the one with the highest index in the list.
Examples:
Names Points Assists
-----------------------
"Joe" 17 30
"John" 21 8
"James" 22 21
John and James each have 20 or more points,
So we only consider John and James for the MVP.
John's total is 29 (21 + 8) and
James' total is 43 (22 + 21) so return "James".
Names Points Assists
-----------------------
"Joe" 10 1
"John" 11 8
"James" 9 21
No player has 20 or more points, so we consider all players.
Return "James", since James' total is 30, which is higher than Joe's (11) and
John's (19).
Names Points Assists
-----------------------
"Adam" 10 20
"John" 11 20
"Harry" 21 9
"Jeff" 25 5
Jeff and Harry both have 20 or more points, and they have the same point and
assist total. Jeff has the highest index (he's closer to the end of the list)
so return "Jeff".
ONE LAST THING:
These players collect their own stats, and, having no morals, they often lie
about them.
There is one way to check on them: The total assists by all players in the
game has to be less than or equal to the total points by all players in the
game.
So, if the total of all assists by players in the game is greater than the
total points for all players in the game, DO NOT return an MVP. Return the
String "CHEATERS".
Example:
Names Points Assists
-----------------------
"Adam" 10 100
"John" 11 80
"Harry" 21 90
"Jeff" 25 50
The total assists for the game is 100 + 80 + 90 + 50 = 320
and the total points for the game is 10 + 11 + 21 + 25 = 67
Your method would return "CHEATERS"
Happy coding!