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
Elena L [17]
2 years ago
7

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 in one int array and the ratings in another int array. Output these arrays (i.e., output the roster). (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
Player 1 -- Jersey number: 84, Rating: 7
Player 2 -- Jersey number: 23, Rating: 4
...
Computers and Technology
1 answer:
aksik [14]2 years ago
5 0

Answer:

import java.util.Scanner;

public class TeamRoster {

  public static void main(String[] args) {

     Scanner scan = new Scanner(System.in);

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

     boolean keepAlive = true;

     char input;

     

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

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

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

        if( players[i][0] >= 0 && players[i][0] < 100 ) {

             System.out.println("Enter player number less than 100");

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

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

               if ( players[i][1] >= 1 && players[i][1] <10 ) {

                     System.out.println();

               }    else {

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

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

               }

     }

     }

     System.out.println();

     outputRoster(players, 0);

     

     while (keepAlive) {

        outputMenu();

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

        if (input == 'q') {

           keepAlive = false;

           break;

        } else if (input == 'o') {

           outputRoster(players, 0);

        } 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 == 'a') {

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

           int rating = scan.nextInt();

           outputRoster(players, rating);

        } 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;

  }

   

  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();

  }

   

  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.

It is a bit straightforward.

The Scanner module is declared and used to collect input from the user.

The program prompts the user for each player jersey then rating.

All five players details are collected.

The program shows the output of all the entries.

You might be interested in
Create pseudocode that could be used as a blueprint for a program that would do the following: An employer wants you to create a
mestny [16]

Answer:

START LOOP FOR EACH EMPLOYEE:

   INPUT employee’s name, hourly rate of pay, number of hours worked, overtime pay rate, payroll deductions, tax rate

   SET gross pay = (hourly rate of pay x *weekly hours) + (overtime pay rate x (number of hours worked - *weekly hours))

   PRINT gross pay

   SET net pay = gross pay - (payroll deductions + (gross pay * tax rate/100 ))

   PRINT net pay

END LOOP

* weekly hours (how many hours an employee needs to work to earn overtime pay rate) is not given in the question

Explanation:

Create a loop that iterates for each employee

Inside the loop, ask for name, hourly rate, number of hours worked, overtime pay rate, payroll deductions, tax rate. Calculate the gross pay and print it. Calculate the net pay and print it

8 0
3 years ago
A network router connects multiple computers together and allows them to send messages to each other. If two or more computers s
Sedbober [7]

Answer:

C = M0(M1+M2+M3)+M1(M2+M3)+M2M3 is the equation which suits

Explanation:

From the given data we can state that we need to activate only one product i.e 1------>activated 0-------->means inactivated and also only one slot is activated at a time.The resultant will be no data inputs n control bits and 2 to the power n output bits.

8 0
3 years ago
Match the careers with the career clusters.
creativ13 [48]
<h2>Answer and Explanation:</h2>

The picture shows the right careers with their respective career clusters.

4 0
2 years ago
Read 2 more answers
How do I persuade my parents to allow me to have social media? I will be 15 in a week or so, so I am old enough. I'm pulling my
Flauer [41]

Answer:

my explanation is above my comment :)

Explanation:

6 0
3 years ago
An engineer is designing an HTML page and wants to specify a title for the browser tab to display, along with some meta data on
Nady [450]

An HTML is made up of several individual tags and elements such as the head, body. form, frame and many more.

In an HTML page, the meta element and the title element are placed in the head element.

An illustration is as follows:

<em>< head > </em>

<em>< title > My Title < /title ></em>

<em>  < meta charset="UTF-8" > </em>

<em>< / head ></em>

<em />

The head element contains quite a number of elements and tags; some of them are:

  • meta
  • title
  • style
  • script
  • base

And so on.

Hence, in order to use a meta-data element, the meta element has to be placed within the head element.

Read more about HTML elements at:

brainly.com/question/4484498

5 0
3 years ago
Other questions:
  • This question involves the implementation of the PasswordGenerator class, which generates strings containing initial passwords f
    5·1 answer
  • When the packet leaves the router, which source and destination ip addresses will be contained in the packet?
    9·1 answer
  • Direct messaging is similar to email, except
    5·2 answers
  • Behaving in an acceptable manner within a workplace environment is referred to as having
    9·1 answer
  • For a wire with a circular cross section and a diameter = 3.00mm calculate the following: (m means meter. mm means millimeter. c
    5·1 answer
  • A provides legal protection for something an individual has created
    12·1 answer
  • ___ is a family of data formats that helps people automatically receive feeds anytime there are new postings to their favorite b
    14·1 answer
  • It is an island country; it fought against us in World War II; it is known for sushi.
    14·2 answers
  • How to use emojis on chromebook without on-screen keyboard
    14·1 answer
  • According to Okun's law, if the unemployment rate goes from 7% to 4%, what
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!