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
zaharov [31]
3 years ago
6

5.27 LAB*: Program: Soccer team roster (Vectors)

Computers and Technology
1 answer:
Setler [38]3 years ago
3 0

Answer:

Explanation:

The following code is written in Java and loops five times asking for the desired inputs from the user and saves that information in two Vectors named jerseyNumber and ratings. Then creates a while loop for the menu and a seperate method for each of the options...

import java.util.Scanner;

import java.util.Vector;

class Brainly {

   static Scanner in = new Scanner(System.in);

   static Vector<Integer> jerseyNumber = new Vector<>();

   static Vector<Integer> ratings = new Vector<>();

   public static void main(String[] args) {

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

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

           jerseyNumber.add(in.nextInt());

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

           ratings.add(in.nextInt());

       }

       boolean reloop = true;

       while (reloop == true) {

           System.out.println("Menu");

           System.out.println("a - Add player");

           System.out.println("d - Remove player");

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

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

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

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

           char answer = in.next().charAt(0);

           switch (answer) {

               case 'a': addPlayer();

                   break;

               case 'd': removePlayer();

                   break;

               case 'u': updatePlayer();

                   break;

               case 'r': outputRating();

                   break;

               case 'o': outputRoster();

                   break;

               case 'q': System.exit(0);

                   reloop = false;

                   break;

           }

       }

   }

   public static void addPlayer() {

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

       jerseyNumber.add(in.nextInt());

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

       ratings.add(in.nextInt());

   }

   public static void removePlayer() {

       System.out.println("Enter Jersey number:");

       int number = in.nextInt();

       for (int x = 0; x < jerseyNumber.size(); x++) {

           if (jerseyNumber.get(x) == number) {

               jerseyNumber.remove(x);

               ratings.remove(x);

           }

       }

   }

   public static void updatePlayer() {

       System.out.println("Enter Jersey number:");

       int number = in.nextInt();

       System.out.println("Enter new Rating:");

       int rating = in.nextInt();

       for (int x = 0; x < jerseyNumber.size(); x++) {

           if (jerseyNumber.get(x) == number) {

               ratings.set(x, rating);

           }

       }

   }

   public static void outputRating() {

       System.out.println("Enter Rating:");

       int rating = in.nextInt();

       for (int x = 0; x < ratings.size(); x++) {

           if (ratings.get(x) >= rating) {

               System.out.println(jerseyNumber.get(x));

           }

       }

   }

   public static void outputRoster() {

       for (int x = 0; x < jerseyNumber.size(); x++) {

           System.out.println("Player " + (x+1) + " -- Jersey number: " + jerseyNumber.get(x) + ", Rating: " + ratings.get(x));

       }

   }

}

You might be interested in
A client wishes to update their legacy system even though there have been no
gulaghasi [49]

Answer:

A client wishes to update their legacy system even though there have been no security breaches since its implementation five years ago. If the client has not suffered any attacks, why is it still necessary to update their system? ... Because new security threats emerge all the time.

8 0
3 years ago
A(n) ______ is a flash memory storage device that contains its own processor to manage its storage.
Ugo [173]
The answer to the fill in the blank is a USB
4 0
3 years ago
Press the enter key in all of the following circumstances except _____.
fiasKO [112]
B. When the insertion point reaches the right margin 
6 0
3 years ago
How good are vw beetle heaters in winter?
Vinvika [58]
It depends on the heater but in most case it works pretty well
7 0
3 years ago
Who invented google​
babymother [125]

Larry Page and Sergey Brin

Are the persons that invented google. This is funny Because is was after googol. mathematically founded by Edward Kasner and James Newman.

Hopes this helps!

7 0
4 years ago
Other questions:
  • when applying styles to a document, which features of the style can be modified in the themes grouping?
    9·2 answers
  • What are three methods of sustainable farming and describe each.
    9·1 answer
  • A(n) __________ is a device or software that is designed to block unauthorized access while allowing authorized communications.
    13·1 answer
  • Consider the scheduling algorithm in the Solaris operating system for time-sharing threads.a. What is the time quantum (in milli
    7·1 answer
  • Alter the line of (10, 20) and (18, 30) en dpoints by (2, 3) scale factor, then move it by (5, 9) translate factor using matrix
    13·1 answer
  • Can you find the ip address from a physical address
    13·1 answer
  • Which of the following is true of e-learning and computer-based training (CBT)?
    13·1 answer
  • Create a cell reference in a formula by typing in the cell name or
    7·2 answers
  • H. What is recycle bin?<br>-&gt;​
    10·1 answer
  • What are different ways that celebrities try to connect with fans using the Internet and social media?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!