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...
This is an intro to Java question. Please include pseudo code for better understanding. I am...
This is an intro to Java question. Please include pseudo code for better understanding. I am hoping to use this to do some reviewing. We are mainly focusing on input and output declarations and invoking API methods. Problem 6: Log It (10 points) Use API (Data Structure Algorithms) High-Low is a simple number guessing game where one player thinks of a random integer number between 0 to some maximum value and another player attempts to guess that number. With each...
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...
C++ Problem. You are coding a simple game called Pig. Players take turns rolling a die....
C++ Problem. You are coding a simple game called Pig. Players take turns rolling a die. The die determines how many points they get. You may get points each turn your roll (turn points), you also have points for the entire game (grand points). The first player with 100 grand points is the winner. The rules are as follows: Each turn, the active player faces a decision (roll or hold): Roll the die. If it’s is a: 1: You lose...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT