Question

In: Computer Science

C++ PLEASE IMPORTANT: The use of vectors is not allowed This program will store roster and...

C++ PLEASE

IMPORTANT:

  • The use of vectors is not allowed

This program will store roster and rating information for a basketball team. Coaches rate players during tryouts to ensure a balanced team. A roster can include at most 10 players.

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

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

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

Ex:

MENU
a - Add player
d - Remove player
u - Update player rating
r - Output players above a rating
o - Output roster
q - Quit

Choose an option:

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

Ex:

ROSTER
Player 1 -- Jersey number: 84, Rating: 7
Player 2 -- Jersey number: 23, Rating: 4
...

(4) Implement the "Add player" menu option. If the user chooses this option and the roster is full, print the following error message:

Impossible to add new player: roster is full.

If the roster is not full, prompt the user for a new player's jersey number and rating, and append the values to the two arrays.

Ex:

Enter a new player's jersey number:
49
Enter the player's rating:
8

(5) Implement the "Delete player" menu option. If the user chooses the option when the roster is empty, immediately print the message:

Can not delete from empty roster.

If the roster is not empty, prompt the user for a player's jersey number. Remove the player from the roster (delete the jersey number and rating), paying attention not to leave unused spaces in the two arrays.

Ex:

Enter a jersey number:
4

If the given jersey number is not found, inform the user:

Error! Player  not found.

(6) 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 look up and change that player's rating.

Ex:

Enter a jersey number:
23
Enter a new rating for player:
6

In this case, if the given jersey number is not found, no further action is taken (note that the format of the program requires both input either way).

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

Enter a rating:
5

ABOVE 5
Player 1 -- Jersey number: 84, Rating: 7
...

If no players are found above a given rating, the program will simply produce an empty list.

BONUS

For an extra 10 points, implement a secret option s that prints the message:

Executing secret option!

and sorts the roster by jersey number. Do not add this option to the MENU message. And remember to move the player rating accordingly!

Solutions

Expert Solution

#include <iostream>

using namespace std;

int main(void)

{

int jerseyNum[10]; // two arrays for jersey number and rating of players

int rating[10];

int i,j,jersey,rate,size = 5;

char option;

cout<<"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

{

cout<<"\nEnter player " <<i+1<< " 's jersey number:";

cin>>jerseyNum[i];

cout<<"\nEnter player "<<i+1<<" 's rating:";

cin>>rating[i];

}

cout<<"\nMENU";

cout<<"\na - Add player";

cout<<"\nd - Delete player";

cout<<"\nu - Update player rating";

cout<<"\nr - Output players above a rating";

cout<<"\no - Output roster";

cout<<"\nq - Quit";

cout<<"\n\n\nChoose an option:";

cin>>option;

do

{

switch(option)

{

case 'a': cout<<"\nEnter another player 's jersey number:";

cin>>jerseyNum[size];

cout<<"\nEnter another player 's rating:";

cin>>rating[size];

size++;

break;

case 'd': cout<<"\nEnter a jersey number : ";

cin>>jersey;

for(i=0;i<size;i++)

{

if(jerseyNum[i] == jersey)

{

for(j=i;j<size;j++)

{

jerseyNum[j] = jerseyNum[j+1];

rating[j] = rating[j+1];

}

}

}

size--;

break;

case 'u': cout<<"\nEnter a jersey number:";

cin>>jersey;

for(i=0;i<size;i++)

{

if(jerseyNum[i] == jersey) //update rating of player

{

cout<<"\nEnter a new rating for player:"<< i+1;

cin>>rating[i];

}

}

break;

case 'r': cout<<"\nEnter a rating:";

cin>>rate;

cout<<"\nABOVE "<<rate;

for(i=0;i<size;i++)

{

if(rating[i] > rate) //find all playershaving rating more than input value

{

cout<<"\nPlayer "<<(i+1)<<" -- Jersey number: "<<jerseyNum[i]<<" Rating:"<<rating[i];

}

}

break;

  

case 'o': cout<<"\nROSTER"; //display data for all players

for(i=0;i<size;i++)

{

cout<<"\nPlayer "<<(i+1)<<" -- Jersey number: "<<jerseyNum[i]<<" Rating:"<<rating[i];

}

break;

case 'q': exit(0); //exit

default: cout<<"\nInvalid option";

break;

}

cout<<"\nChoose an option:";

cin>>option;

}while(option != 'q');

return 0;

}

Output:

Enter five pairs of numbers: A player's jersey number (0 -99) and the player's rating (1 - 9)
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
MENU
a - Add player
d - Delete player
u - Update player rating
r - Output players above a rating
o - Output roster
q - Quit


Choose an option:o
ROSTER
Player 1 -- Jersey number: 84 Rating:7
Player 2 -- Jersey number: 23 Rating:4
Player 3 -- Jersey number: 4 Rating:5
Player 4 -- Jersey number: 30 Rating:2
Player 5 -- Jersey number: 66 Rating:9
Choose an option:a
Enter another player 's jersey number:49
Enter another player  's rating:8
Choose an option:o
ROSTER
Player 1 -- Jersey number: 84 Rating:7
Player 2 -- Jersey number: 23 Rating:4
Player 3 -- Jersey number: 4 Rating:5
Player 4 -- Jersey number: 30 Rating:2
Player 5 -- Jersey number: 66 Rating:9
Player 6 -- Jersey number: 49 Rating:8
Choose an option:d
Enter a jersey number : 4
Choose an option:o
ROSTER
Player 1 -- Jersey number: 84 Rating:7
Player 2 -- Jersey number: 23 Rating:4
Player 3 -- Jersey number: 30 Rating:2
Player 4 -- Jersey number: 66 Rating:9
Player 5 -- Jersey number: 49 Rating:8
Choose an option:u
Enter a jersey number:23
Enter a new rating for player:6
Choose an option:r
Enter a rating:5
ABOVE 5
Player 1 -- Jersey number: 84 Rating:7
Player 2 -- Jersey number: 23 Rating:6
Player 4 -- Jersey number: 66 Rating:9
Player 5 -- Jersey number: 49 Rating:8
Choose an option:q

Do ask if any doubt. Please upvote.


Related Solutions

C++ 18.27 LAB*: Program: Soccer team roster (Vectors) This program will store roster and rating information...
C++ 18.27 LAB*: Program: Soccer team roster (Vectors) 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: Enter...
Please write in C. This program will store roster and rating information for a soccer team....
Please write in 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 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:...
C code please This program will store roster and rating information for a soccer team. Coaches...
C code please 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). (3 pts) Ex: Enter player 1's jersey number: 84...
Program: Soccer team roster This program will store roster and rating information for a soccer team....
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) 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:...
C++ this program will store roster and rating information for a soccer team. Coaches rate players...
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). Ex: Enter player 1's jersey number: 84 Enter player 1's rating:...
Soccer team roster (Dictionaries) This program will store roster and rating information for a soccer team.
Soccer team roster (Dictionaries) 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 and the ratings in a dictionary. Output the dictionary's elements with the jersey numbers in ascending order (i.e., output the roster from smallest to largest jersey...
Please do not use vectors or any previously posted code Write a C++ program which reads...
Please do not use vectors or any previously posted code Write a C++ program which reads in a list of process names and integer times from stdin/cin and simulates round-robin CPU scheduling on the list. The input is a list of lines each consisting of a process name and an integer time, e.g. ProcessA 4 ProcessB 10 Read line by line until an end-of-transmission (^d) is encountered. You should read the list and represent it in a linked list data...
Write this program in C++ language. Use the concept of structures. DO NOT use vectors. Q...
Write this program in C++ language. Use the concept of structures. DO NOT use vectors. Q (4) Create a structure called time. Its three members, all type int, should be called hours, minutes, and seconds. Write a program that prompts the user to enter a time value in hours, minutes, and seconds. This should be in 12:59:59 format. This entire input should be assigned first to a string variable. Then the string should be tokenized thereby assigning the 1st token...
This program will store roster and rating information for a soccer team. Coaches rate players during...
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). (3 pts) Ex: Enter player 1's jersey number: 84 Enter player 1's...
This program will store roster and rating information for a basketball team. Coaches rate players during...
This program will store roster and rating information for a basketball team. Coaches rate players during tryouts to ensure a balanced team. A roster can include at most 10 players. (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...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT