Question: IN Java, Calculate and output which Baller is the Postman in the driver - the Baller gets the most rebounds on average, with a label

IN Java, Calculate and output which Baller is the Postman in the driver - the Baller gets the most rebounds on average, with a label and the rebounds.

Below is the code I have so far plus the txt files they read from:

import java.io.File;

import java.io.FileNotFoundException;

import java.io.FileReader;

import java.util.ArrayList;

import java.util.Scanner;

public class P5Driver {

public static void main(String[] args) throws FileNotFoundException

{

System.out.println("Welcome");

ArrayList Ballers= new ArrayList();

int c = 0;

@SuppressWarnings("resource")

Scanner scan = new Scanner(new File("BBallers.txt"));

while(scan.hasNextLine()) {

String line = scan.nextLine();

String[] tokens = line.split(",");

if(tokens.length == 3) {

Ballers.add(new Ballers(tokens[0], tokens[1], tokens[2]));

System.out.println( Ballers.get(c).getName());

c++;

}

}

for(int i = 0; i < Ballers.size(); i++) {

Ballers.get(i).toString();

}

}

}

import java.text.DecimalFormat;

public class BoxScore {

private int points;

private int rebounds;

private int assists;

private int goalsMade;

private int goalsAttempted;

private double fieldPer;

private DecimalFormat dForm = new DecimalFormat("0.00");

//

public void setPoints(int p)

{

points = p;

}

public int getPoints()

{

return points;

}

//

public void setRebounds(int r)

{

rebounds = r;

}

public int getRebounds()

{

return rebounds;

}

//

public void setAssists(int a)

{

assists = a;

}

public int getAssists()

{

return assists;

}

//

public void setGoalsMade(int gm)

{

goalsMade = gm;

}

public int getGoalsMade()

{

return goalsMade;

}

//

public void setGoalsAttempted(int gm)

{

goalsAttempted = gm;

}

public int getGoalsAttempted()

{

return goalsAttempted;

}

//

public void setFieldPer(double fp)

{

fieldPer = goalsMade/goalsAttempted;

}

public double getFieldPer()

{

return fieldPer;

}

//

public String toString()

{

String str = " Field goals made: " + goalsMade + " Field goals attempted: " + goalsAttempted +

" Field goal percentage: " + fieldPer + "Points: " + points + " Rebounds: " + rebounds +

" Assists: " + assists;

return str;

}

public DecimalFormat getDForm() {

return dForm;

}

public void setDForm(DecimalFormat dForm) {

this.dForm = dForm;

}

}

import java.util.ArrayList;

public class Ballers {

private String name;

private String team;

private String initials;

private double fieldPer;

double avg;

ArrayList BoxScore;

//

public Ballers(){

name = "";

team = "";

initials = "";

}

public Ballers(String n, String t, String i){

name = n;

team = t;

initials = i;

}

public void setName(String n)

{

name = n;

}

public String getName()

{

return name;

}

//

public void setTeam(String t)

{

team = t;

}

public String getTeam()

{

return team;

}

//

public void setInitials(String i)

{

initials = i;

}

public String getInitials()

{

return initials;

}

//

public void setFieldPer(double fp)

{

// BoxScore.get(i).setFieldPer(fp);

}

public double getFieldPer()

{

return fieldPer;

}

//

public ArrayList getBoxScoreList()

{

return BoxScore;

}

//

public String toString()

{

String str = " Name: " + name + " Team: " + team + " Initials: " + initials;

return str;

}

//method to output data

public void printData() {

for(int i = 0; i

BoxScore.get(i).toString();

}

}

//method to quick sort

public static int partition(ArrayList s2, int mini, int max)

{

double pivot = s2.get(mini).getFieldPer();

int left = mini;

int right = max;

while(left

{

while(s2.get(left).getFieldPer()<=pivot && left

{

left++;

}

while(s2.get(right).getFieldPer()>=pivot)

{

right--;

}

if(left

{

swap(s2, left, right);

}

}

swap(s2, mini, right);

return right;

}

//method to get average points

public void calcAverage0() {

double total = 0.00;

for(int i = 0; i < BoxScore.size(); i++) {

total += BoxScore.get(i).getPoints();

}

avg = total/BoxScore.size();

}

//method to get average rebounds

public void calcAverage1() {

double total = 0.00;

for(int i = 0; i < BoxScore.size(); i++) {

total += BoxScore.get(i).getRebounds();

}

avg = total/BoxScore.size();

}

//method to get average assists

public void calcAverage2() {

double total = 0.00;

for(int i = 0; i < BoxScore.size(); i++) {

total += BoxScore.get(i).getAssists();

}

avg = total/BoxScore.size();

}

//method to get average attempts

public void calcAverage3() {

double total = 0.00;

for(int i = 0; i < BoxScore.size(); i++) {

total += BoxScore.get(i).getAssists();

}

avg = total/BoxScore.size();

}

}

Txt files:

BBallers:

Ben Simmons,Philadelphia 76ers,P76 Lebron James,Cleveland Cavaliers,CC Kevin Durant,Golden State Warriors,GSW James Harden,Houston Rockets,HR Giannis Antetokounmpo,Milwaukee Bucks,MB Jason Tatum,Boston Celtics,BC Russell Westbrook,Oklahoma City Thunder,OCT DeMar DeRozan,Toronto Raptors,TR Dwyane Wade,Miami Heat,MH Bradley Beal,Washington Wizards,WW Anthony Davis,New Orleans Pelicans,NOP Damian Lillard,Portland Trail Blazers,PTB LaMarcus Aldridge,San Antonio Spurs,SAS

BScores:

P76,7,10,16,7,9 MH,3,9,7,5,3 BC,8,12,19,4,2 OCT,10,28,24,7,10 HR,7,16,26,4,9 TR,5,17,12,5,8 MB,7,21,19,10,7 CC,17,29,44,11,11 GSW,9,25,34,10,4 WW,12,24,32,3,3 NOP,8,17,25,11,3 PTB,11,22,33,3,5 SAS,9,19,25,11,2 GSW,6,11,17,4,9 MB,11,22,29,11,6 TR,6,17,16,3,2 BC,4,10,8,4,3 SAS,13,22,28,8,1 MH,5,11,11,4,6 NOP,13,24,34,12,4 P76,12,17,27,15,13 HR,8,19,25,3,8 WW,7,15,19,9,8 OCT,15,26,44,16,6 PTB,6,20,29,5,8 CC,12,24,27,9,11 SAS,12,20,28,9,4 OCT,9,17,26,15,13 BC,5,13,20,2,2 NOP,6,19,16,8,3 PTB,7,15,27,3,9 WW,10,15,27,4,3 HR,12,18,38,10,9 GSW,16,26,41,10,5 P76,7,10,16,6,7 MB,8,20,27,16,4 MH,5,16,13,4,4 CC,12,20,33,9,14 TR,7,13,19,3,7 PTB,5,16,17,7,11 WW,5,17,15,4,5 NOP,11,25,31,16,2 TR,12,19,32,7,7 BC,9,16,24,6,4 GSW,8,23,27,5,7 CC,8,14,27,10,10 OCT,12,32,33,9,13 HR,8,21,28,8,10 SAS,13,21,35,9,1 P76,7,10,15,12,6 MB,14,18,32,4,5 MH,2,7,8,3,4 PTB,18,33,41,9,6 SAS,11,19,23,14,2 NOP,15,24,36,14,4 WW,8,14,22,4,3 MH,5,11,12,2,4 TR,7,12,15,1,8 OCT,7,19,19,11,5 BC,6,15,16,2,3 MB,10,16,26,9,7 HR,6,15,18,10,15 GSW,12,19,29,11,8 CC,5,21,16,13,12 P76,10,17,20,8,15

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!