Question

5.22 LAB*: Program: Soccer team roster steam This program will store roster and rating information for a soccer team Coaches
g (2) Implement a menu of options for a user to modify the roster. Each option is represented by a single character outputs t
Enter a rating: ABOVE 5 Player Jersey number 04. Rating: 7 (6) Implement the Replace player menu option Promot the user for
Player Roster.java Load default template 1 import java.util.Scanners public class Player Roster public static void main(Strin
0 0
Add a comment Improve this question Transcribed image text
Answer #1

// PlayerRoster.java
import java.util.Scanner;

public class PlayerRoster {

   public static void main(String[] args) {

       Scanner scnr = new Scanner(System.in);
       int jersey[] = new int[5];
       int rating[] = new int[5];
      
       // input of jersey number and rating of 5 players
       for(int i=0;i<jersey.length;i++)
       {
           System.out.println("Enter player "+(i+1)+"'s jersey number: ");
           jersey[i] = scnr.nextInt();
          
           System.out.println("Enter player "+(i+1)+"'s rating: ");
           rating[i] =scnr.nextInt();
          
           System.out.println();
       }
      
       scnr.nextLine();
       // display the roster
       System.out.println("\nROSTER");
       for(int i=0;i<jersey.length;i++)
       {
           System.out.println("Player "+(i+1)+" -- Jersey number: "+jersey[i]+", Rating: "+rating[i]);
       }
      
       String choice;
       int jerseyNo, plRating;
       // loop that continues till the user quits
       do
       {
           // display the menu
           System.out.println("\nMENU");
           System.out.println("u - Update player rating");
           System.out.println("a - Output player above a rating");
           System.out.println("r - Replace player");
           System.out.println("o - Output roster");
           System.out.println("q - Quit");
           System.out.print("\nChoose a option: ");
           choice = scnr.nextLine(); // input the choice
          
           // update player rating
           if(choice.equalsIgnoreCase("u"))
           {
               System.out.println("Enter a jersey number: ");
               jerseyNo = scnr.nextInt();
               System.out.println("Enter a new player rating: ");
               plRating = scnr.nextInt();
               scnr.nextLine();
               for(int i=0;i<jersey.length;i++)
               {
                   if(jersey[i] == jerseyNo)
                   {
                       rating[i] = plRating;
                       break;
                   }
               }
           } // output players above a rating
           else if(choice.equalsIgnoreCase("a"))
           {
               System.out.println("Enter a rating: ");
               plRating = scnr.nextInt();
               scnr.nextLine();
               System.out.println("\nABOVE "+plRating);
               for(int i=0;i<jersey.length;i++)
               {
                   if(rating[i] > plRating)
                       System.out.println("Player "+(i+1)+" -- Jersey number: "+jersey[i]+", Rating: "+rating[i]);
               }
           }// replace player
           else if(choice.equalsIgnoreCase("r"))
           {
               System.out.println("Enter a jersey number: ");
               jerseyNo = scnr.nextInt();
               for(int i=0;i<jersey.length;i++)
               {
                   if(jersey[i] == jerseyNo)
                   {
                       System.out.println("Enter a new jersey number: ");
                       jersey[i] = scnr.nextInt();
                       System.out.println("Enter a rating for the new player: ");
                       rating[i] = scnr.nextInt();
                       break;
                   }
               }
              
               scnr.nextLine();
           }// output roster
           else if(choice.equalsIgnoreCase("o"))
           {
               System.out.println("\nROSTER");
               for(int i=0;i<jersey.length;i++)
               {
                   System.out.println("Player "+(i+1)+" -- Jersey number: "+jersey[i]+", Rating: "+rating[i]);
               }
           }
          
       }while(!choice.equalsIgnoreCase("q"));
   }

}
//end of PlayerRoster.java

Output:

Enter player ls jersey number: 84 Enter player ls rating: Enter player 2s jersey number: 23 Enter player 2s rating: Enter

Enter a jersey number: 23 Enter a new player rating: MENU u - Update player rating a - Output player above a rating r - Repla

MENU u - Update player rating a - Output player above a rating r - Replace player 0 - Output roster q - Quit Choose a option:

Add a comment
Know the answer?
Add Answer to:
5.22 LAB*: Program: Soccer team roster steam This program will store roster and rating information for...
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
  • Java 7.17 Clone of LAB*: Program: Soccer team roster This program will store roster and rating...

    Java 7.17 Clone of LAB*: Program: Soccer team roster This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balanced team. (1) Prompt the user to input five pairs of numbers: A player's jersey number (0-99, but this is NOT enforced by the program nor tested) and the player's rating (1-9, not enforced like jersey numbers). Store the jersey numbers in one int array and the ratings in another int...

  • 5.19 Ch 5 Program: Soccer team roster (Vectors) (C++) This program will store roster and rating...

    5.19 Ch 5 Program: Soccer team roster (Vectors) (C++) This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balanced team. (1) Prompt the user to input five pairs of numbers: A player's jersey number (0 - 99) and the player's rating (1 - 9). Store the jersey numbers in one int vector and the ratings in another int vector. Output these vectors (i.e., output the roster). (3 pts) Ex:...

  • 5.19 Lab 11b: Soccer team roster Instructor note: NOTE Unlike our other assignments, this one has...

    5.19 Lab 11b: Soccer team roster Instructor note: NOTE Unlike our other assignments, this one has only two programs: People's Weights and this one. To earn 30 points, you must do both assignments. Allow ample time to complete them Passing arrays to methods Review Chapter 6.8 Array Parameters if you wish to use methods in your program (a good idea). Since we pass a reference to the array's location in memory, changes made to the array within the method will...

  • In C Program This program will store the roster and rating information for a soccer team. There w...

    In C Program This program will store the roster and rating information for a soccer team. There will be 3 pieces of information about each player: Name: string, 1-100 characters (nickname or first name only, NO SPACES) Jersey Number: integer, 1-99 (these must be unique) Rating: double, 0.0-100.0 You must create a struct called "playData" to hold all the information defined above for a single player. You must use an array of your structs to to store this information. You...

  • This program will store a roster of most popular videos with kittens. The roster can include...

    This program will store a roster of most popular videos with kittens. The roster can include at most 10 kittens.You will implement structures to handle kitten information. You will also use functions to manipulate the structure. (1) Create a structure kitten. The structure should contain the following attributes: name; string color; string score; integer Important! The name of the structure and each of its field must match exactly for the program to work and be graded correctly. (2) Create a...

  • (C++) Write a program that declares a struct to store the data of a football player...

    (C++) Write a program that declares a struct to store the data of a football player (player’s name, player’s position, number of touchdowns, number of catches, number of passing yards, number of receiving yards, and the number of rushing yards). Declare an array of 10 components to store the data of 10 football players. Your program must contain a function to input data and a function to output data. Add functions to search the array to find the index of...

  • #PLEASE WRITE THE CODE IN JAVA! THANK YOU IN ADVANCE! Write a program that manages a...

    #PLEASE WRITE THE CODE IN JAVA! THANK YOU IN ADVANCE! Write a program that manages a list of up to 10 players and their high scores in the computer's memory. Use two arrays to manage the list. One array should store the players' names, and the other array should store the players' high scores. Use the index of the arrays to correlate the names with the scores. Your program should support the following features: a. Add a new player and...

  • Chapter 8 Python Case study Baseball Team Manager For this case study, you’ll use the programming...

    Chapter 8 Python Case study Baseball Team Manager For this case study, you’ll use the programming skills that you learn in Murach’s Python Programming to develop a program that helps a person manage a baseball team. This program stores the data for each player on the team, and it also lets the manager set a starting lineup for each game. After you read chapter 2, you can develop a simple program that calculates the batting average for a player. Then,...

  • c++ A menu-driven program gives the user the option to find statistics about different baseball players....

    c++ A menu-driven program gives the user the option to find statistics about different baseball players. The program reads from a file and stores the data for ten baseball players, including player’s team, name of player, number of homeruns, batting average, and runs batted in. (You can make up your data, or get it online, for example: http://espn.go.com/mlb/statistics ) Write a program that declares a struct to store the data for a player. Declare an array of 10 components to...

  • Case Study Baseball Team Manager. CMSC 135 Python Chapter 7 Assignment: Use a file to save...

    Case Study Baseball Team Manager. CMSC 135 Python Chapter 7 Assignment: Use a file to save the data Update the program so it reads the player data from a file when the program starts andwrites the player data to a file anytime the data is changed What needs to be updated: Specifications Use a CSV file to store the lineup. Store the functions for writing and reading the file of players in a separate module than the rest of the...

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