Question

5.19 Lab 11b: Soccer team roster Instructor note: NOTE Unlike our other assignments, this one has only two programs: PeoplesEX. Enter player 1s jorscy number: Enter player ls rating: Enter player 2s jersey number: 2.3 Entor playr 2s rating: EnteROSTER Player 1 erscy number: 84, Rating: 7 Player 2 -Jersey number: 23, Rating: 4 (2) Implement a menu of options for a user4) Implement the Update player rating menu option. Prompt the user for a players jersey number. Prompt again for a new ratiJersey number: 84-Rating:ー7 (6) Implement the Replace player menu option. Prompt the user for the jersey number of the play

5.19 Lab 11b: Soccer team roster Instructor note: NOTE Unlike our other assignments, this one has only two programs: People's Weights and this one. To earn 30 points, you must do both assignments. Allow ample time to complete them Passing arrays to methods Review Chapter 6.8 Array Parameters if you wish to use methods in your program (a good idea). Since we pass a reference to the array's location in memory, changes made to the array within the method will persist when the method completes. This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balanced 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). (4 pts) Ex Enter playcr 1's jorscy number: 84 Enter player 1's rating:
EX. Enter player 1's jorscy number: Enter player l's rating: Enter player 2's jersey number: 2.3 Entor playr 2's rating: Enter player 3's jersey number: nter player 3's rating: Enter player 's jersey number: 30 Enter player 4's rating: Enter player 5's jersey number: Enter playcr 5's rating: ROSTER Player 1Jersey number: 84, RaLing:7 2 3
ROSTER Player 1 erscy number: 84, Rating: 7 Player 2 -Jersey number: 23, Rating: 4 (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. (4 pt) Ex: MENU u - Update player rating a -Oulpul players above a raLing r- Replace player OuLpul rosler T - Quit Choosc an option: (3) Implement the "Output roster menu option. (2 pt) Ex: Player 1--Jersey number: 4, Rating: Player2 -dersey number: 23, Rat.ing: 4
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. (3 pt) Ex: Enter a jersey number: 23 Enter a new rating tor player: (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. (5 pts) Ex Enl.er a ral.ing: ABOVE 5 Player 1Jersey number: 84, Ral.ing: 7 (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. (4 pts) Ex Enl.er a jersey number:
Jersey number: 84-Rating:ー7 (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. (4 pts) Ex Enter a jersey number: Enter a new jersey number: 12 Enter a rating for the new player: LAB ACTIVITY 5.19.1: Lab 11b: Soccer team roster 0/ 20 PlayerRoster.java Load default template 1 import java.util.Scanner 3 public class PlayerRoster 4 public static void main(String[] args) *Type your code here.
0 0
Add a comment Improve this question Transcribed image text
Answer #1

1 import java.util.Scanner; 2 class Main 3 public static void main(String[] args) 4 Scanner keyboardnew Scanner (System.in);

31 if(jersey[ind] jnum) 32 System.out.print(Enter a new rating:: rating[ind] - keyboard.nextInt); 34 35 36 37 38 39 40 41 e

61 // finding the index for(ind 0; ind < count && jersey[ind] != jnun; ind++); if(jersey[ind]jnum) 63 64 65 // taking input o

import java.util.Scanner;

class Main {

public static void main(String[] args) {

Scanner keyboard = new Scanner(System.in);

int[] jersey = new int[5];

int[] rating = new int[5];

int count = 0;

char choice = 'o';

// taking input of 5 members

for(count = 0; count<5; count++)

{

System.out.printf("Enter player %d's jersey number:\n", count+1);

jersey[count] = keyboard.nextInt();

System.out.printf("Enter player %d's rating:\n", count+1);

rating[count] = keyboard.nextInt();

}

while(true)

{

if(choice == 'u')

{

System.out.print("\nEnter a jersey number: ");

int jnum = keyboard.nextInt();

// finding the index of that jersey

int ind = 0;

for(ind = 0; ind < count && jersey[ind] != jnum; ind++);

// taking rating

if(jersey[ind] == jnum)

{

System.out.print("Enter a new rating: ");

rating[ind] = keyboard.nextInt();

}

}

else if(choice == 'a')

{

// taking input of rating

System.out.print("\nEnter a rating: ");

int above = keyboard.nextInt();

int track = 1;

System.out.println("\nABOVE " + above);

// printing only if the rating is above that

for(int i=0; i<count; i++)

{

if(rating[i] > above)

System.out.printf("Player %d -- Jersey number: %d, Rating: %d\n",track++,jersey[i],rating[i]);

}

}

else if(choice == 'r')

{

// taking jersey number

System.out.print("\nEnter a jersey number: ");

int jnum = keyboard.nextInt();

int ind = 0;

// finding the index

for(ind = 0; ind < count && jersey[ind] != jnum; ind++);

if(jersey[ind] == jnum)

{

// taking input of other rating and number and updating

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

jersey[ind] = keyboard.nextInt();

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

rating[ind] = keyboard.nextInt();

}

}

else if(choice == 'o')

{

// printing the roster

System.out.println("\nROSTER");

for(int i=0; i<count; i++)

{

System.out.printf("Player %d -- Jersey number: %d, Rating: %d\n",i+1,jersey[i],rating[i]);

}

}

System.out.println("\nMENU\nu - Update player rating\na - Output players above a rating\nr - Replace player\no - Output roster\nq - Quit");

choice = keyboard.next().charAt(0);

if(choice == 'q')

break;

}

}

}

/* OUTPUT

ROSTER

Player 1 -- Jersey number: 3, Rating: 4

Player 2 -- Jersey number: 5, Rating: 2

Player 3 -- Jersey number: 8, Rating: 4

Player 4 -- Jersey number: 9, Rating: 4

Player 5 -- Jersey number: 7, Rating: 9

MENU

u - Update player rating

a - Output players above a rating

r - Replace player

o - Output roster

q - Quit

u

Enter a jersey number: 3

Enter a new rating: 6

MENU

u - Update player rating

a - Output players above a rating

r - Replace player

o - Output roster

q - Quit

o

ROSTER

Player 1 -- Jersey number: 3, Rating: 6

Player 2 -- Jersey number: 5, Rating: 2

Player 3 -- Jersey number: 8, Rating: 4

Player 4 -- Jersey number: 9, Rating: 4

Player 5 -- Jersey number: 7, Rating: 9

MENU

u - Update player rating

a - Output players above a rating

r - Replace player

o - Output roster

q - Quit

a

Enter a rating: 4

ABOVE

Player 1 -- Jersey number: 3, Rating: 6

Player 2 -- Jersey number: 7, Rating: 9

MENU

u - Update player rating

a - Output players above a rating

r - Replace player

o - Output roster

q - Quit

r

Enter a jersey number: 7

Enter a new jersey number: 6

Enter a rating for the new player: 1

MENU

u - Update player rating

a - Output players above a rating

r - Replace player

o - Output roster

q - Quit

o

ROSTER

Player 1 -- Jersey number: 3, Rating: 6

Player 2 -- Jersey number: 5, Rating: 2

Player 3 -- Jersey number: 8, Rating: 4

Player 4 -- Jersey number: 9, Rating: 4

Player 5 -- Jersey number: 6, Rating: 1

MENU

u - Update player rating

a - Output players above a rating

r - Replace player

o - Output roster

q - Quit

q

*/

Add a comment
Know the answer?
Add Answer to:
5.19 Lab 11b: Soccer team roster Instructor note: NOTE Unlike our other assignments, this one has...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Java 7.17 Clone of LAB*: Program: Soccer team roster This program will store roster and rating...

    Java 7.17 Clone of LAB*: Program: Soccer team roster This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balanced team. (1) Prompt the user to input five pairs of numbers: A player's jersey number (0-99, but this is NOT enforced by the program nor tested) and the player's rating (1-9, not enforced like jersey numbers). Store the jersey numbers in one int array and the ratings in another int...

  • 5.19 Ch 5 Program: Soccer team roster (Vectors) (C++) This program will store roster and rating...

    5.19 Ch 5 Program: Soccer team roster (Vectors) (C++) This program will store roster and rating information for a soccer team. Coaches rate players during tryouts to ensure a balanced 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 vector and the ratings in another int vector. Output these vectors (i.e., output the roster). (3 pts) Ex:...

  • 5.22 LAB*: Program: Soccer team roster steam This program will store roster and rating information for...

    5.22 LAB*: Program: Soccer team roster steam This program will store roster and rating information for a soccer team Coaches rate players during tryouts to ensure (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 in one int array and the ratings in another int array Output these arrays (e. output the roster) (3 pts) numbers EX Enter player 1 jersey number: Enter player l's rating: Enter player...

  • In C Program This program will store the roster and rating information for a soccer team. There w...

    In C Program This program will store the roster and rating information for a soccer team. There will be 3 pieces of information about each player: Name: string, 1-100 characters (nickname or first name only, NO SPACES) Jersey Number: integer, 1-99 (these must be unique) Rating: double, 0.0-100.0 You must create a struct called "playData" to hold all the information defined above for a single player. You must use an array of your structs to to store this information. You...

  • This program will store a roster of most popular videos with kittens. The roster can include...

    This program will store a roster of most popular videos with kittens. The roster can include at most 10 kittens.You will implement structures to handle kitten information. You will also use functions to manipulate the structure. (1) Create a structure kitten. The structure should contain the following attributes: name; string color; string score; integer Important! The name of the structure and each of its field must match exactly for the program to work and be graded correctly. (2) Create a...

  • Chapter 8 Python Case study Baseball Team Manager For this case study, you’ll use the programming...

    Chapter 8 Python Case study Baseball Team Manager For this case study, you’ll use the programming skills that you learn in Murach’s Python Programming to develop a program that helps a person manage a baseball team. This program stores the data for each player on the team, and it also lets the manager set a starting lineup for each game. After you read chapter 2, you can develop a simple program that calculates the batting average for a player. Then,...

  • (C++) Write a program that declares a struct to store the data of a football player...

    (C++) Write a program that declares a struct to store the data of a football player (player’s name, player’s position, number of touchdowns, number of catches, number of passing yards, number of receiving yards, and the number of rushing yards). Declare an array of 10 components to store the data of 10 football players. Your program must contain a function to input data and a function to output data. Add functions to search the array to find the index of...

  • Case Study Baseball Team Manager. CMSC 135 Python Chapter 7 Assignment: Use a file to save...

    Case Study Baseball Team Manager. CMSC 135 Python Chapter 7 Assignment: Use a file to save the data Update the program so it reads the player data from a file when the program starts andwrites the player data to a file anytime the data is changed What needs to be updated: Specifications Use a CSV file to store the lineup. Store the functions for writing and reading the file of players in a separate module than the rest of the...

  • In this project, you will use functions and dictionaries to track basketball players and their respective...

    In this project, you will use functions and dictionaries to track basketball players and their respective points, then display statistics of points made. You will need three functions as follows: def freeThrowMade(playerDictionary, playerName) - this function will add 1 point to the player's total score def twoPointMade(playerDictionary, playerName) - this function will add 2 points to the player's total score def threePointMade(playerDictionary, playerName) - this function will add 3 points to the player's total score Each of these functions has...

  • C++ Language Overview: Design an APP for a basketball team with a unique name. There should be at least 10 players. The member variables required include team member’s names, jersey number, position p...

    C++ Language Overview: Design an APP for a basketball team with a unique name. There should be at least 10 players. The member variables required include team member’s names, jersey number, position played, and at least 3 stats. Positions are small forward, power forward, center, shooting guard and point guard. 1. A.) Design a class with member variables and appropriate member functions Data should be stored in a read/write file consisting of team member’s names, jersey number, position played, and...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT