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]
3 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]3 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
What makes it possible for e-mail to be sent and received on a wide variety of devices, including cell phones, PDAs, laptops, an
Usimov [2.4K]

Answer:

Compatibility.

Explanation:

Email or electronic mail is a messaging system that allows for transmission of digital or electronic mails to computers within and to other networks through the internet.

Email applications are web based applications and are hosted on servers. The POP (post office protocol) and IMAP (internet messaging access protocol) are used to message the mails sent to a client on a server. The application is written with standards and protocols to ensure compatibility in all types of device form factor, so an email can be view in a laptops, smartphones etc.

4 0
3 years ago
"Look at the following code. Which line will cause a compiler error?
crimeas [40]

Answer:

i got a feeling c

Explanation:

5 0
3 years ago
Each device attached to your computer comes with a special program called a(n ________ that enables the device and operating sys
Serhud [2]
Driver- comes with a driver installed.
7 0
4 years ago
You are troubleshooting a connectivity problem in your corporate network and want to isolate the problem. You suspect that a rou
FromTheMoon [43]

Answer:

Something

Explanation:

Idk

3 0
4 years ago
In which decade did personal computers become commonplace in offices, schools, and some homes?
iren [92.7K]
The decade in which the personal computers became commonplace in offices, schools, and some homes were the 1980s. 
8 0
3 years ago
Other questions:
  • What is information reach? A. A global public network of computer networks that pass information from one to another using commo
    5·1 answer
  • Which bus slot provides highest video performance​
    13·1 answer
  • An image can be copied from the Internet or another location and pasted into Paint.
    13·1 answer
  • What is a software? 2 sentences please, I'll mark u as brailiest
    12·1 answer
  • In this exercise, first run the code as it is given to see the intended output. Then trace through each of the 3 variables to se
    8·1 answer
  • With the Linux operating system, its open source design means it can be used, modified and ______
    10·1 answer
  • Write a program that takes two decimal numbers as input and print the largest. If the numbers are equal, print one of them.
    13·1 answer
  • The ______________<br> holds data only while the computer is on.
    7·1 answer
  • Help me with this question asap please :)
    14·1 answer
  • What do the last two steps in the cyclical design process most likely involve
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!