Problem Statement | |||||||||||||
In basketball, players can attempt either two point or three point field goals, and if they are fouled, they can also attempt one point free throws. Since missing a free throw or a field goal often results in losing possession of the ball, it is important to make the most of each shot attempt. Traditionally, this efficiency has been measured by shooting percentage, which is defined as:
Field goals made Shooting percentage = --------------------- Field goals attempted Unfortunately, this formula is problematic since it does not account for either free throws or the different types of field goals. Therefore, a new formula, called points per shot, is gaining prominence. This is given by: Total points Points per shot = ----------------------------------------------------- (Field goals attempted) + 0.5*(Free throws attempted) Consider, for example, a player that makes 4 of 5 two point field goals, 3 of 7 three point field goals, and 7 of 9 free throws. The player has earned 4*2 + 3*3 + 7*1 = 24 points with 5+7=12 field goal attempts and 9 free throw attempts. Thus, the player has earned 24/16.5 = 1.45454545... points per shot. Create a class ScoringEfficiency that contains a method getPointsPerShot, which is given a String[] gameLog. This will give the history of one player's shot attempts, with each element being equal to one of the following strings (quotes for clarity):
| |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Notes | |||||||||||||
- | Return values with either a relative or absolute error less than 1.0E-9 will be accepted. | ||||||||||||
Constraints | |||||||||||||
- | gameLog will contain between 1 and 50 elements inclusive. | ||||||||||||
- | Each element of gameLog will be one of the six strings listed above. | ||||||||||||
Examples | |||||||||||||
0) | |||||||||||||
| |||||||||||||
1) | |||||||||||||
| |||||||||||||
2) | |||||||||||||
| |||||||||||||
3) | |||||||||||||
|