Question

Write a Java program segment (not an entire program) that will summarize the season results for...

Write a Java program segment (not an entire program) that will summarize the season results for 5 players on one of TRU’s basketball teams. Each player played 10 games.

Your program segment should ask the user for a player’s name, followed by the points that player scored in each of the 10 games (a total of 11 pieces of input). Your program will then produce the summary line shown below for that player.  

Your program should get the data for each of the remaining 4 players and produce a summary line for those as well.

Your program should produce the summary in the format shown below, for each player.   ( not the actual data, for illustration purposes only)    

NOTES: PPG = average points per game (format to one decimal place)

High = highest points in one of the 10 games
Low = lowest points in one of the 10 games
( you may assume the highest and lowest points occurred only once each)

This is the summary you will produce, including the 2 lines at the end:

                Player              PPG       High        Low

              Name 1           20.1        29            11       

repeat the same summary for each of the remaining 4 players

   Name 3 had the highest one game result of 31 points in game #7

   Name 2 had the lowest one game result of 5 points in game #5.

Homework Answers

Answer #1

/*JAVA segment code is written and explained below from main method */

public static void main(String[] args) {
       /*Here is the code java codde segment that
       * you need to have inside main function of
       * any java class, that is
       * "public static void main(String[] args) { } *****************/
      
       int number_of_players=5;
      
      
       /*Now we will tell make a array for storing summary of each player */
       int player_score[][]=new int[5][10];
       String player_name[]=new String[5];
       Double ppg=10.0;
       Double PPG=0.0;
  
      
      
       /*Below we need to use Scanner object ,
       * which is used for taking input from user in java language*/
      
       Scanner sc=new Scanner(System.in);
      
       for(int i=0;i<number_of_players;i++)
       {
           int sum=0;
           System.out.println("Enter Player's Name for player number: "+(i+1));
           player_name[i]=sc.next();
          
          
          
          
          
           System.out.println("Now please enter the scores of player "+ (i+1)+ " till 10th match");
           for(int j=0;j<10;j++)
           {
               player_score[i][j]=sc.nextInt();
           sum+=player_score[i][j];/*This sum will help in calculaing average that is PPG*/
           }/*Closing Inner for loop*/
          
          
          
          
           /*calculating PPG as shown below is for getting
           * average, as PPG is average, we will divide it
           * by 10 as there are 10 matches only */
           /***************IMPORTANT**********
           * Here we used "Math.round which on
           * multiplying and dividing by ten "10" will
           * give us answer up to one decimal place.
           * If we use hundred "100" , we will get
           * answer rounded off up to 2 decimal places and so on "*/
          
           PPG= Math.round((sum/ppg) * 10.0) / 10.0;
          
             
             
             
             
           /*Code for calculating maximum of the player score*/
           int max=0;
           for(int j=0;j<10;j++)
           {
               if(max<player_score[i][j])
               {
                   max=player_score[i][j];
               }
           }
             
             
             
             
             
             
             
           /*Code for calculating minimum of the player score*/
           int min=Integer.MAX_VALUE;
           for(int j=0;j<10;j++)
           {
               if(min>player_score[i][j])
               {
                   min=player_score[i][j];
               }
           }
             
             
             
             
             
             
             
             
           System.out.println("Summary of Player "+(i+1)+" is ");
          
             
             
           /******************PRINTING SUMMARY*****************/
           System.out.println("PLAYER PPG High LOW");
           System.out.println(player_name[i]+" "+PPG+" "+max+" "+min);
          
           System.out.println();
              
          
       }/*Closing outer for loop*/

}/*Closing main method*/

Know the answer?
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
Similar Questions
Write a Python program to manage league matches. Different teams can participate in a league. A...
Write a Python program to manage league matches. Different teams can participate in a league. A player belongs to a team and a team can play many games in a league. For each team the league wants to track the name of the team and the number of players in each team. The league also wants to track the number of games the team has played, and the total numbers of points scored across all games played. During each game...
Write a program that allows two players to play a game of tic-tac-toe. Use a twodimensional...
Write a program that allows two players to play a game of tic-tac-toe. Use a twodimensional char array with three rows and three columns as the game board. Each element in the array should be initialized with an asterisk (*). The program should run a loop that: • Displays the contents of the board array. • Allows player 1 to select a location on the board for an X. The program should ask the user to enter the row and...
Write the Game class, Java lanuage. A Game instance is described by three instance variables: gameName...
Write the Game class, Java lanuage. A Game instance is described by three instance variables: gameName (a String), numSold (an integer that represents the number of that type of game sold), and priceEach (a double that is the price of each of that type of Game). I only want three instance variables!! The class should have the following methods: A constructor that has two parameter – a String containing the name of the Game and a double containing its price....
In Java. Write a program that reads-in a times table-number. The program, using this table-number will...
In Java. Write a program that reads-in a times table-number. The program, using this table-number will produce the following report (as shown). The first item in the report is a number with starting value 1. Second column is the word “ X ” (representing the times symbol). Third column is the table-number (itself). Following is an equal sign “ = “ (representing a result). Last column is the result of the operation for that line or row which is the...
JAVA: MUST BE DONE IN JAVA Assignment: Write algorithms and programs to play “non-betting” Craps. Craps...
JAVA: MUST BE DONE IN JAVA Assignment: Write algorithms and programs to play “non-betting” Craps. Craps is a game played with a pair of dice. In the game, the shooter (the player with the dice) rolls a pair of dice and the number of spots showing on the two upward faces are added up. If the opening roll (called the “coming out” roll) is a 7 (“natural”) or 11 (“yo-leven”), the shooter immediately wins the game. If the coming out...
C++ Programming   You are to develop a program to read Baseball player statistics from an input...
C++ Programming   You are to develop a program to read Baseball player statistics from an input file. Each player should bestored in a Player object. Therefore, you need to define the Player class. Each player will have a firstname, last name, a position (strings) and a batting average (floating point number). Your class needs to provide all the methods needed to read, write, initialize the object. Your data needs to be stored in an array of player objects. The maximum...
Project 2 statement Please write this in JAVA. Please read this entire statement carefully before you...
Project 2 statement Please write this in JAVA. Please read this entire statement carefully before you start doing anything… This project involves implementing a simple university personnel management program. The program contains two different kinds of objects: students and faculty. For each object, the program stores relevant information such as university ID, name, etc. Different information is stored depending on the type of the object. For example, a student has a GPA, while a faculty has a title and department...
In java create a dice game called sequences also known as straight shooter. Each player in...
In java create a dice game called sequences also known as straight shooter. Each player in turn rolls SIX dice and scores points for any sequence of CONSECUTIVE numbers thrown beginning with 1. In the event of two or more of the same number being rolled only one counts. However, a throw that contains three 1's cancels out player's score and they mst start from 0. A total of scores is kept and the first player to reach 100 points,...
JAVA ASSIGNMENT 1. Write program that opens the file and process its contents. Each lines in...
JAVA ASSIGNMENT 1. Write program that opens the file and process its contents. Each lines in the file contains seven numbers,which are the sales number for one week. The numbers are separated by comma.The following line is an example from the file 2541.36,2965.88,1965.32,1845.23,7021.11,9652.74,1469.36. The program should display the following: . The total sales for each week . The average daily sales for each week . The total sales for all of the weeks .The average weekly sales .The week number...
Program will allow anywhere between 1 and 6 players (inclusive). Here is what your output will...
Program will allow anywhere between 1 and 6 players (inclusive). Here is what your output will look like: Enter number of players: 2 Player 1: 7S 5D - 12 points Player 2: 4H JC - 14 points Dealer: 10D Player 1, do you want to hit? [y / n]: y Player 1: 7S 5D 8H - 20 points Player 1, do you want to hit? [y / n]: n Player 2, do you want to hit? [y / n]: y...