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
Implement the following problem as a self-contained Python program (module). Please write in beginner level code!...
Implement the following problem as a self-contained Python program (module). Please write in beginner level code! Thanks! The game of Pig is a simple two-player dice game in which the first player to reach 100 or more points wins. Players take turns. On each turn, a player rolls a six-sided die. After each roll: a) If the player rolls a 1 then the player gets no new points and it becomes the other player’s turn. b) If the player rolls...
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...
One of the most popular games of chance is a dice game known as “craps”, played...
One of the most popular games of chance is a dice game known as “craps”, played in casinos around the world. Here are the rules of the game: A player rolls two six-sided die, which means he can roll a 1, 2, 3, 4, 5 or 6 on either die. After the dice come to rest they are added together and their sum determines the outcome. If the sum is 7 or 11 on the first roll, the player wins....
R-S-P Requirement: - write one C++ program that mimics the Rock-Scissor-Paper game. This program will ask...
R-S-P Requirement: - write one C++ program that mimics the Rock-Scissor-Paper game. This program will ask user to enter an input (out of R-S-P), and the computer will randomly pick one and print out the result (user wins / computer wins). - User's input along with computer's random pick will be encoded in the following format: -- user's rock: 10 -- user's scissor:          20 -- user's paper:            30 -- comp's rock:            1 -- comp's scissor:        2 -- comp's...
Create in JAVA Suppose you are designing a game called King of the Stacks. The rules...
Create in JAVA Suppose you are designing a game called King of the Stacks. The rules of the game are as follows:  The game is played with two (2) players.  There are three (3) different Stacks in the game.  Each turn, a player pushes a disk on top of exactly one of the three Stacks. Players alternate turns throughout the game. Each disk will include some marker to denote to whom it belongs.  At the end...
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...
For this assignment, you'll create a Player class that captures information about players on a sports...
For this assignment, you'll create a Player class that captures information about players on a sports team. We'll keep it generic for this assignment, but taking what you learn with this assignment, you could create a class tailored to your favorite sport. Then, imagine using such a class to track the stats during a game. Player Class Requirements Your class should bet set up as follows: Named Player Is public to allow access from other object and assemblies Has a...
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...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT