Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Two-dimensional arrays are very useful for organizing large amounts of data. have the following data on the number of points scored by each player on
Two-dimensional arrays are very useful for organizing large amounts of data. have the following data on the number of points scored by each player on a basketball team over each game of a seven-game series: 1. For example, suppose you Player Tim the Enchanter Dora the Explorer Catherine the Great Suleiman the Donald the I braces to quickly instantiate a 2-D array with specific values. Examples Assume that the previous table of data is stored in a 2-D array named s. Then, 20 27 23 20 27 14 cent 17 21 15 . averagePPG(s, 2) should return Catherine the Great's average points per game (which is .singleGameScore(s, 0) should return the total points scored by the whole team for Game 0 (which is . averageGameScore(s) should return the average total points scored by the whole team per game (38 1925 221925 + 31)/ 7 = 25.57) This information can be stored in a 2-D array, where each row of the array represents a player and each column represents a game. Index [] of this aray is the number of points scored by player j in gamej (where both and f start counting from 0)-for example, index [O][5] would be the number of points scored by Tim the Enchanter in Game 5. Write the following methods (3 pts each) to process data stored in this format: 20 +83817+2-85) (which s (85 + 73 + 69 + 83 + 73 + 66 + 62) / 7=73.0) singleGameTopSsoringPlayeris, 2) should returm the index of the top-scoring player in Game 2 (which is 2, for Catherine the Great) 2. public static double aeragePPG(intlll scores, int p) This should return the average points per game of player p, based on the data in the aray scores. Note that although I'm using the specific values in the table for these examples, your methods should be written so that they work properly for any rectangular 2-D array of data in the samc format (i.c, they should work for a different number of players and/or a different aumber of games) 3. public static int singleGameScoreintll scores, int g) This should retun the total points scored (by the entire team) in game g, based on the data in the array 4. public static double averageGameScore(intl scores) This should return the average total points scored (by the entire team) per game, based on the data in the armay scores 5. public static int singleGameTopScoringPlayerint scores, int g) This should return the index of the highest-scoring player in game g, based on the data in the array scores. 6. public statie void main(StringlI args) The main method should declare and instantiate a 2-D array containing the above data, then call your methods on it to verify they're working properly. Remember that you can use shorthand notation with curly
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started