Question

Here are 10 basketball players with their average points per game.        Adam, John, Charlie, Doug, Tommy,...

Here are 10 basketball players with their average points per game.       

Adam, John, Charlie, Doug, Tommy, Frank, Gerry, Henry, Bill,   Jimmy

5.8,      10.7,     15.3,    9.0,     13.4,     21.1,   9.2,     14.5,  11.3, 7.5

Write a Java program to identify and print out the player names with the highest and lowest average point per game. You must use arrays or array lists to solve this problem.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

BaskkeBallTest.java


public class BaskkeBallTest {

   public static void main(String[] args) {
       String players[] = {"Adam", "John", "Charlie", "Doug", "Tommy", "Frank", "Gerry", "Henry", "Bill", "Jimmy"};
       double points[] = {5.8, 10.7, 15.3, 9.0, 13.4, 21.1, 9.2, 14.5, 11.3, 7.5};
       double max = points[0], min = points[0];
       String    highestPlayer = players[0], lowestPlayer = players[0];
       for(int i=0;i<points.length;i++) {
           if(max < points[i]) {
               max = points[i];
               highestPlayer = players[i];
           }
           if(min > points[i]) {
               min = points[i];
               lowestPlayer = players[i];
           }
       }
       System.out.println("Higest Player: "+highestPlayer);
       System.out.println("Lowest Player: "+lowestPlayer);
   }

}

Output:

Higest Player: Frank
Lowest Player: Adam

Add a comment
Know the answer?
Add Answer to:
Here are 10 basketball players with their average points per game.        Adam, John, Charlie, Doug, Tommy,...
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
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
ADVERTISEMENT