Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

This program will store roster and rating information for a soccer team. Coaches

ID: 3938069 • Letter: T

Question

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

*NOTE* this is in java. Please do not use floats :)

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

Ex:

(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.

Ex:

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

Ex:

(4) 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.

Ex:

(5) 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.

Ex:

(6) Implement the "Replace player" menu option. Prompt the user for the jersey number of the player to replace. If the player is in the roster, then prompt again for a new jersey number and rating. Update the replaced player's jersey number and rating.

Ex:

Explanation / Answer

import java.util.*;
import java.lang.*;
import java.io.*;


class Roster
{
public static void main (String[] args)
{
int[] jerseyNum = new int[5]; // two arrays for jersey number and rating of players
int[] rating = new int[5];
int i;
Scanner scan = new Scanner(System.in);
System.out.println("Enter five pairs of numbers: A player's jersey number (0 - 99) and the player's rating (1 - 9)");
  
for(i=0;i<5;i++) //enter data for 5 players
{
System.out.println("Enter player "+(i+1) +"'s jersey number:");
jerseyNum[i] = scan.nextInt();
System.out.println("Enter player "+(i+1) +"'s rating:");
rating[i] = scan.nextInt();
}
  
  
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");
System.out.println("Choose an option:");
  
char option = scan.next().charAt(0);
  
do
{
switch(option)
{
case 'u': System.out.println("Enter a jersey number:");
int jersey = scan.nextInt();
for(i=0;i<5;i++)
{
if(jerseyNum[i] == jersey) //update rating of player
{
System.out.println("Enter a new rating for player: " +(i+1));
rating[i] = scan.nextInt();
}
}
break;
case 'a': System.out.println("Enter a rating:");
int rate= scan.nextInt();
System.out.println("ABOVE "+rate);
for(i=0;i<5;i++)
{
if(rating[i] > rate) //find all players having rating more than input value
{
System.out.println("Player "+(i+1)+" -- Jersey number: "+jerseyNum[i]+", Rating:"+rating[i]);
}
}
break;
case 'r':   System.out.println("Enter a jersey number of the player to replace :");
           jersey = scan.nextInt();
           for(i=0;i<5;i++)
           {
               if(jerseyNum[i] == jersey) //replace player with new jersey number and rating
               {
               System.out.println("Enter a new jersey number: ");
   int jerseynew =scan.nextInt();
   jerseyNum[i] = jerseynew;
   System.out.println("Enter a rating for the new player:");
   rate = scan.nextInt();
   rating[i] = rate;
               }
           }
break;
case 'o': System.out.println("ROSTER"); //display data for all players
for(i=0;i<5;i++)
{
System.out.println("Player "+(i+1)+" -- Jersey number: "+jerseyNum[i]+", Rating:"+rating[i]);
  
}
break;
case 'q': System.exit(0); //exit
  
default: System.out.println("Invalid option");
break;
  
}
System.out.println("Choose an option:");
option = scan.next().charAt(0);
  
}while(option != 'q');
}
}

output:

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote