Question

public class StatsAnalyzer { public static int PlayerTotalPoints(int[] [] scores, int p) { // assuming the 1st player data is
return bestIdx; public static int teamPointsPerGame(int[] [] scores, int g) { int points = 0; for(int i 0; i < scores. Length
*public static int teamBestGame(int[] [] scores) This returns the index of the game in which the entire team scored the most
0 0
Add a comment Improve this question Transcribed image text
Answer #1
Thanks for the question.

Below is the code you will be needing  Let me know if you have any doubts or if you need anything to change.

Thank You !!

===========================================================================

public class StatsAnalyzer {


    public static int PlayerTotalPoints(int[][] scores, int p) {

        // assuming the 1st player data is at index 0 and
        // last player index is at p-1 index
        if (0 <= p && p < scores.length) {
            int totalPoints = 0;
            // player p data will be in row scores[p]
            for (int game = 0; game < scores[p].length; game++) {
                totalPoints += scores[p][game];
            }
            return totalPoints;
        }
        return 0;

    }

    public static double playerAvgPoints(int[][] scores, int p) {

        // assuming the 1st player data is at index 0 and
        // last player index is at p-1 index
        if (0 <= p && p < scores.length) {
            double totalPoints = 0;
            // player p data will be in row scores[p]
            for (int game = 0; game < scores[p].length; game++) {
                totalPoints += scores[p][game];
            }
            // divide totalpoints by game count to get average
            return totalPoints / scores[p].length;
        }
        return 0;
    }

    public static int teamPointsPerGame(int[][] scores, int g) {
        int points = 0;
        for (int i = 0; i < scores.length; i++) {
            points += scores[i][g];
        }
        return points;
    }

    public static int teamBestGame(int[][] scores) {
        int bestGameIndex = 0;
        int bestGameTotalPoints = 0;
        for (int game = 0; game < scores[0].length; game++) {
            int gameTotalPoints = teamPointsPerGame(scores, game);
            if (gameTotalPoints > bestGameTotalPoints) {
                bestGameTotalPoints = gameTotalPoints;
                bestGameIndex = game;
            }
        }
        return bestGameIndex;
    }

    public static int lowestScoringPlayer(int[][] scores) {

        int lowestScoringPlayerIndex = 0;
        int lowestScore = Integer.MAX_VALUE;
        for (int player = 0; player < scores.length; player++) {

            for (int game = 0; game < scores[player].length; game++) {
                if (scores[player][game] < lowestScore) {
                    lowestScore = scores[player][game];
                    lowestScoringPlayerIndex = player;
                }
            }
        }
        return lowestScoringPlayerIndex;
    }
}

===========================================================================

Thanks, let me know for any questions or in case you encounter any issue.


Please do give a thumbs up from your end : )

Add a comment
Know the answer?
Add Answer to:
public class StatsAnalyzer { public static int PlayerTotalPoints(int[] [] scores, int p) { // assuming the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • I need this done in C++ Can someone help me get my code from crashing. The...

    I need this done in C++ Can someone help me get my code from crashing. The code compiles but it can be easily crashed with user input. The rubric and code below Instructions: Write a program that scores the following data about a soccer player in a structure:            Player’s Name            Player’s Number            Points Scored by Player      The program should keep an array of 12 of these structures. Each element is for a different player on a...

  • Need done in C++ Can not get my code to properly display output. Instructions below. The...

    Need done in C++ Can not get my code to properly display output. Instructions below. The code compiles but output is very off. Write a program that scores the following data about a soccer player in a structure:            Player’s Name            Player’s Number            Points Scored by Player      The program should keep an array of 12 of these structures. Each element is for a different player on a team. When the program runs, it should ask the user...

  • Q21 Read the following code: 8 Points public class Main { public static int[][] doStuff() {...

    Q21 Read the following code: 8 Points public class Main { public static int[][] doStuff() { int[][] array2D = new int[3][2]; for (int i = 0; i < array2D.length; i++) { for (int j = 0; j < array2D[0].length; j++) { array2D[i][j] = (i+j)%2; } } return array2D; فه public static void main(String[] args) { int[][] a = doStuff(); مہ سره Q21.1 What are the contents of array a? 6 Points Write your answer as if printing the elements row-by-row....

  • You will implement the following method public static int[] linearSearchExtended(int[][] numbers, int key) { // Implement...

    You will implement the following method public static int[] linearSearchExtended(int[][] numbers, int key) { // Implement this method return new int[] {}; }    There is a utility method provided for you with the following signature. You may use this method to convert a list of integers into an array. public static int[] convertIntegers(List<Integer> integers) Provided code import java.util.ArrayList; import java.util.Iterator; import java.util.List; import java.util.Scanner; public class MatrixSearch { // This method converts a list of integers to an array...

  • must provide the following public interface: public static void insertSort(int [] arr); public static void selectSort(int...

    must provide the following public interface: public static void insertSort(int [] arr); public static void selectSort(int [] arr); public static void quickSort(int [] arr); public static void mergeSort(int [] arr); The quick sort and merge sort must be implemented by using recursive thinking. So the students may provide the following private static methods: //merge method //merge two sorted portions of given array arr, namely, from start to middle //and from middle + 1 to end into one sorted portion, namely,...

  • public class play { public static final int ONE_PAIR = 1000000; public static final int TWO_PAIRS...

    public class play { public static final int ONE_PAIR = 1000000; public static final int TWO_PAIRS = 2000000; public static final int THREE_OF_A_KIND = 3000000; public static final int STRAIGHT = 4000000; public static final int FLUSH = 5000000; public static final int FULL_HOUSE = 6000000; public static final int FOUR_OF_A_KIND = 7000000; public static final int STRAIGHT_FLUSH = 8000000;    public static boolean isOnepair(Card[] cards) { if (cards.length != 5) return false; if (isFourOfAKind(cards) || isFullHouse(cards) || isThreeOfAKind(cards) ||...

  • import java.util.Arrays; public class lab {    public static void main(String args[])    {    int...

    import java.util.Arrays; public class lab {    public static void main(String args[])    {    int arr[] = {10, 7, 8, 9, 1, 5,6,7};    int arr2[] = {9, 8, 7, 6, 5, 4, 3, 2, 1};    int arr3[] = {1, 3, 5, 3, 2, 6, 20};    quicksort(arr,0,arr.length-1);    quicksort(arr2,0,arr2.length-1);    quicksort(arr3,0,arr3.length-1);    System.out.println(Arrays.toString(arr));    System.out.println(Arrays.toString(arr2));    System.out.println(Arrays.toString(arr3));       }    private static int partition(int[] items,int low, int high)    {    int i=0;    int j=0;...

  • public class FirstLastNameEvent { public final static int ppg = 35; public final static int cutoff...

    public class FirstLastNameEvent { public final static int ppg = 35; public final static int cutoff = 50; private String eventNumber; private int guestNumber; private int price; public void setEventNumber(String eventNumber) { this.eventNumber = eventNumber; } public void setGuestNumber(int guestNumber) { this.guestNumber = guestNumber * ppg; } public String getEventNumber() { return eventNumber; } public int getGuestNumber() { return guestNumber; } public int getPrice() { return price; } } Using Assignment #3’s code:(the code above) Modify the ‘public static void...

  • package cards; import java.util.ArrayList; import java.util.Scanner; public class GamePlay { static int counter = 0; private...

    package cards; import java.util.ArrayList; import java.util.Scanner; public class GamePlay { static int counter = 0; private static int cardNumber[] = {1,2,3,4,5,6,7,8,9,10,11,12,13}; private static char suitName[] = { 'c', 'd', 'h', 's' }; public static void main(String[] args) throws CardException, DeckException, HandException { Scanner kb = new Scanner(System.in); System.out.println("How many Players? "); int numHands = kb.nextInt(); int cards = 0; if (numHands > 0) { cards = 52 / numHands; System.out.println("Each player gets " + cards + " cards\n"); } else...

  • public class NumStack implements Comparable{ private Integer[] data; private int index; public NumStack(int cap){ data=new Integer[cap];...

    public class NumStack implements Comparable{ private Integer[] data; private int index; public NumStack(int cap){ data=new Integer[cap]; index =-1; } public boolean isEmpty(){ return index == -1; } public boolean isFull(){ return index==data.length -1; } public NumStack pop(){ if(!isEmpty()) data[index--]=null; return this; } public int size(){ return index+1; } public Integer top(){ if(isEmpty()) return null; return data[index]; } public NumStack push(int num){ if(index < data.length-1) data[++index]=num; return this; } public int compareTo(NumStack s){} } public int compareTo(NumStack s) compares two stack...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT