1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Ivahew [28]
3 years ago
5

This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balance

d 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 and the ratings in a dictionary. Output the dictionary's elements with the jersey numbers in ascending order (i.e., output the roster from smallest to largest jersey number). Hint: Dictionary keys can be stored in a sorted list. (3 pts)

Ex: Enter player 1's jersey number: 84 Enter player 1's rating: 7 Enter player 2's jersey number: 23 Enter player 2's rating: 4 Enter player 3's jersey number: 4 Enter player 3's rating: 5 Enter player 4's jersey number: 30 Enter player 4's rating: 2 Enter player 5's jersey number: 66 Enter player 5's rating: 9 ROSTER Jersey number: 4, Rating: 5 Jersey number: 23, Rating: 4 Jersey number 30, Rating: 2 ...

(2) Implement a menu of options for a user to modify the roster. Each option is represented by a single character. The program initially outputs the menu, and outputs the menu after a user chooses an option. The program ends when the user chooses the option to Quit. For this step, the other options do nothing. (2 pts)

Ex: MENU a - Add player d - Remove player u - Update player rating r - Output players above a rating o - Output roster q - Quit Choose an option:

(3) Implement the "Output roster" menu option.

Ex: ROSTER Jersey number: 4, Rating: 5 Jersey number: 23, Rating: 4 Jersey number 30, Rating: 2 ...

(4) Implement the "Add player" menu option. Prompt the user for a new player's jersey number and rating. Append the values to the two vectors. (1 pt)

Ex: Enter a new player's jersey number: 49 Enter the player's rating: 8

(5) Implement the "Delete player" menu option. Prompt the user for a player's jersey number. Remove the player from the roster (delete the jersey number and rating). (1 pt)

Ex: Enter a jersey number: 4

(6) Implement the "Update player rating" menu option. Prompt the user for a player's jersey number. Prompt again for a new rating for the player, and then change that player's rating. (1 pt)

Ex: Enter a jersey number: 23 Enter a new rating for player: 6

(7) Implement the "Output players above a rating" menu option. Prompt the user for a rating. Print the jersey number and rating for all players with ratings above the entered value. (2 pts)

Ex: Enter a rating: 5 ABOVE 5 Jersey number: 66, Rating: 9 Jersey number: 84, Rating: 7 ...
Computers and Technology
1 answer:
Simora [160]3 years ago
5 0

Answer:

// Scanner class is imported to allow program receive user input

import java.util.Scanner;

// class is defined

public class PlayerRoster {

   // main method that begin program execution

  public static void main(String[] args) {

   // Scanner object scan is defined

     Scanner scan = new Scanner(System.in);

   // multi-dimensional array to hold the jersey number and rating

     int[][] players = new int[5][2];

   // boolean flag to keep program alive

     boolean keepAlive = true;

   // the user input is declared as input of type char

     char input;

     

   // for loop that receive 5 player jersey number and ratings

   // it assigns the received input to the already initialized array

     for (int i = 0; i < 5; i++) {

        System.out.println("Enter player " + (i+1) + "'s jersey number: ");

        players[i][0] = scan.nextInt();

        System.out.println("Enter player " + (i+1) + "'s rating: ");

        players[i][1] = scan.nextInt();

        System.out.println();

     }

   // a blank line is printed

     System.out.println();

   // a method is called to display players array

     outputRoster(players, 0);

     

   // while the flag is true

   // display the Menu by calling the outputMenu method

     while (keepAlive) {

        outputMenu();

       // user input is assigned to input

        input = scan.next().charAt(0);

       //  if user input is 'q' then program will quit

        if (input == 'q') {

           keepAlive = false;

           break;

        }

       //  else if input is o, then outputRoaster is called to display players

        else if (input == 'o') {

           outputRoster(players, 0);

        }

       //  else if input is 'u', then user is allowed to edit a player rating

        else if (input == 'u') {

           System.out.println("Enter a jersey number: ");

           int jerseyNum = scan.nextInt();

           System.out.println("Enter a new rating for the player: ");

           int newRating = scan.nextInt();

           for (int l = 0; l < 5; l++) {

              if (players[l][0] == jerseyNum) {

                 players[l][1] = newRating;

              }

           }

        }

       //  else if input is 'a', user is allowed to add a new rating

        else if (input == 'a') {

           System.out.println("Enter a rating: ");

           int rating = scan.nextInt();

           outputRoster(players, rating);

        }

        // else if input is 'r', user is allowed to replace a player

        else if (input == 'r') {

           System.out.println("Enter a jersey number: ");

           int jerseyNum = scan.nextInt();

           boolean exists = true;

           for (int l = 0; l < 5; l++) {

              if (players[l][0] == jerseyNum) {

                 System.out.println("Enter a new jersey number: ");

                 players[l][0] = scan.nextInt();

                 System.out.println("Enter a rating for the new player: ");

                 players[l][1] = scan.nextInt();

              }

           }

           

        }

     }

     

     return;

  }

 

// this method take two parameters, players and min

// it then returns player with ratings greater than min

  public static void outputRoster(int[][] players, int min) {

     System.out.println(((min>0) ? ("ABOVE " + min) : ("ROSTER")));

     int item = 1;

     for (int[] player : players) {

        if (player[1] > min) {

           System.out.println("Player " + item + " -- Jersey number: " + player[0] + ", Rating: " + player[1]);

        }

        item++;

     }

     System.out.println();

  }

 

// outputMenu method to display the program menu

  public static void outputMenu() {

     System.out.println("MENU");

     System.out.println("u - Update player rating");

     System.out.println("a - Output players above a rating");

     System.out.println("r - Replace player");

     System.out.println("o - Output roster");

     System.out.println("q - Quit\n");

     System.out.println("Choose an option: ");  

  }

}

Explanation:

The program is written in Java and it is well commented.                                          

You might be interested in
____ is a philosophy and a software and system development methodology that focuses on the development, use, and reuse of small,
LiRa [457]

Answer:

d.) Service-Oriented Architecture

Explanation:

Because its definition matches

4 0
3 years ago
Which feature of a website takes you to a different part of the website or a totally different website when you click on it?
lesantik [10]

A hyperlink is a feature that takes you to a different page when you click on it. That page could be part of the same website or a totally different website.

Let me know if you have any questions.

3 0
3 years ago
Read 2 more answers
To quickly save a file, use the keyboard shortcut ________. ctrtl shift s ctrl s ctrl a ctrl shift-a
Advocard [28]
You have to use control + s only. but if you want to save it in different format, use control + shift + S
3 0
2 years ago
What is cyber crime ? easy definition​
Naddika [18.5K]

Answer:

Cyber crime is defined as a crime in which a computer is the object of the crime (hacking, phishing, spamming) or is used as a tool to commit an offense .

Explanation:

4 0
2 years ago
Open IDLE. Create a new script file (File--&gt;New File, Ctrl n on Windows, Cmd n on macOS). On the first line, place your name
Lorico [155]

Answer:

program:

#your name

print("{:10} {:10} {:10}".format("Number","Square","Cube"))

print("{:<10} {:<10} {:<10}".format(0,0,0))

print("{:<10} {:<10} {:<10}".format(1,1,1))

print("{:<10} {:<10} {:<10}".format(2,2**2,2**3))

print("{:<10} {:<10} {:<10}".format(3,3**2,3**3))

print("{:<10} {:<10} {:<10}".format(4,4**2,4**3))

print("{:<10} {:<10} {:<10}".format(5,5**2,5**3))

print("{:<10} {:<10} {:<10}".format(6,6**2,6**3))

print("{:<10} {:<10} {:<10}".format(7,7**2,7**3))

print("{:<10} {:<10} {:<10}".format(8,8**2,8**3))

print("{:<10} {:<10} {:<10}".format(9,9**2,9**3))

print("{:<10} {:<10} {:<10}".format(10,10**2,10**3))

output:

Number Square Cube

0 0 0

1 1 1

2 4 8

3 9 27

4 16 64

5 25 125

6 36 216

7 49 343

8 64 512

9 81 729

10 100 1000

6 0
2 years ago
Other questions:
  • You need to upgrade memory in a system but you don't have the motherboard documentation available. you open the case and notice
    9·1 answer
  • Trish has bought a new computer that she plans to start working on after a week. Since Trish has not used computers in the past,
    10·1 answer
  • This question is for one of my classes I am in right now, and the question is:
    8·1 answer
  • 2.
    11·1 answer
  • Given that n refers to a positive int use a while loop to compute the sum of the cubes of the first n counting numbers, and asso
    12·1 answer
  • High level language - An object oriented programming language​
    5·1 answer
  • 2. The Internet could best be described as: *
    12·1 answer
  • What is the first step a user should take toward generating an index?
    7·1 answer
  • I need more friends plz talk with me
    6·2 answers
  • The cameras picture review function allows you to look at the _ you've taken
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!