Question

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 will need an array capable of holding the information for 10 players.

You should initialize the struct elements of your array with appropriate values.

--------------------------------------------------------------------------------

You need to implement the following 2 functions to validate the user's input AND
use them in your implementation:


  bool jerseyValid(int playeJerseyNumber);
bool ratingValid(double playerRating);


If the input value is not valid,
then the function returns false otherwise it should return true.

If the input data is not valid,
then break from the input process and redisplay the menu.

--------------------------------------------------------------------------------

You need to implement the following function AND use it your implementation

  void printPlayer(playerData* thisPlayer);

This function will take a pointer to a player information struct
and print all the information for one player, formatted as shown below:
Player Name
Player Jersey #
Player Rating

--------------------------------------------------------------------------------

Your program will need to implement the following function:


int findPlayer(int whichPlayer, const int jerseyNumbers[], int maxJersyCount);

This function takes a player jersey 3 (whichPlay) and looks for that value in the jerseyNumber array.

If found...return the index number
If NOT found...return a -1

You will need this function!

--------------------------------------------------------------------------------

You will implement a menu of options for the user to build and modify the roster. Each option is represented by a single character. The program initially outputs the menu, prompts the user for a choice and then processes that choice (HINT: this is a good place to use a switch statement.) The menu is provided as part of the start code and looks like this:


MENU
a - Add a new player
u - Update player information
r - Remove a player from the roster
d - Display player information
p - Print the full roster
s - Print "Star" players
q - Quit

Please make a selection:

Each option should operate as follows:
--------------------------------------------------------------------------------

a - Add a new player, prompts the user as follows
Enter player jersey number:
Enter player first or nick name:
Enter player rating:

NOTE: lookup the player info by jersey number...
if found...display an error message and return to the menu
if not found...enter the data as above

NOTE: If the maximum number of players has been entered...
display an error message and return to the menu

NOTE: You do not need to validate the range of the rating.

(HINT: entering the player name can be done with a scanf)

--------------------------------------------------------------------------------

u - Update player information
Enter player jersey number:

NOTE: lookup the player info by jersey number...
if found...prompt for name and rating as in option 'a'
if not found...display an error message and return to the menu

NOTE: You do not need to validate the range of the rating.

--------------------------------------------------------------------------------

r - Remove a player from the roster
Enter player jersey number:

NOTE: lookup the player info by jersey number...
if found...remove the player
if not found...display an error message and return to the menu

--------------------------------------------------------------------------------

d - Display player information
Enter player jersey number:

Display the following:
Name:
Jersey #:
Rating:

NOTE: lookup the player info by jersey number...
if found...display the information
if not found...display an error message and return to the menu

--------------------------------------------------------------------------------

p - Print the full roster
Prints all the information for all the players:

ROSTER
-------
Player Name 1
Player Jersey #
Player Rating

Player Name 2
Player Jersey #
Player Rating

... for as many players as have been entered ...

--------------------------------------------------------------------------------

s - Print "STAR" players
Prints all the players with a rating greater than the star rating
Prompt the user as follows:

Enter "STAR" rating:

MY STARS
--------
Player Name 1
Player Jersey #
Player Rating

Player Name 2
Player Jersey #
Player Rating

... for as many players as meet the criteria...
and there may be none!

--------------------------------------------------------------------------------

q - Quit
Normal exit for the program

--------------------------------------------------------------------------------

HINT 1: Start with the EASY menu options, like quit. You can also create a player using assignment statements and implement the printing options before tackling the add player and delete player operations.

HINT 2: There are 2 ways to approach this project and the arrays.
- Keep a player count and then move data when removing players.
- Use an illegal jersey # when removing players (this is the easier approach)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Note: Could you plz go through this code and let me know if u need any changes in this.Thank You
_________________

#include <stdio.h>
#include <string.h>
#include <stdlib.h>

// function declarations
int getValidJerseyNumber();
int getValidRating();

int main()
{

// declaring variables
int s=50;
   int size=5,count=5;
int jerseyNo[s];
int rating[s];
char name[s][30];
int i = 0, jno, rate,j;
char option;

/* Getting the inputs entered by the user
* and populate the values into arrays
*/
for (i = 0; i < size; i++)
{
  
printf("\nEnter player %d's jersey number :\n", i + 1);
jerseyNo[i] = getValidJerseyNumber();
  
       printf("Enter player first or nick name:\n");
       scanf("%s",&name[i]);
printf("\nEnter player %d's rating :\n", i + 1);
rating[i] = getValidRating();
}

printf("\nROSTER\n");
for (i = 0; i < size; i++)
{
printf("Player %d -- Jersey Number:%d, Name:%s, Rating:%d\n", i + 1, jerseyNo[i],name[i],rating[i]);
}
/* This while loop continues to execute
* until the user enters a valid option or 'q/Q'
*/
while (1)
{
// displaying the menu
printf("\nMENU");
printf("\na - Add a new player");
printf("\nu - Update player information");
       printf("\nr - Remove a player from the roster");
       printf("\nd - Display player information");
       printf("\np - Print the full roster");
       printf("\ns - Print \"Star\" players");
       printf("\nq - Quit");

       printf("\nPlease make a selection:");
scanf(" %c", &option);

// Based on the user choice the corresponding case will be executed
switch (option)
{
case 'a':
case 'A':
{
printf("\nEnter a new player's jersey number :\n");
jerseyNo[count] = getValidJerseyNumber();

   printf("Enter player first or nick name:");
       scanf("%s",&name[count]);
      
printf("\nEnter the player's rating :\n");
rating[count] = getValidRating();
  
count++;
continue;
}
case 'u':
case 'U':
{
   char newName[40];
   double newrate;
int flag = 0;
int indx=0;
printf("Enter a jersey number :\n");
jno = getValidJerseyNumber();
  
for (i = 0; i < count; i++)
{
if (jerseyNo[i] == jno)
{
indx=i;;
flag = 1;
}
}
if (flag == 0)
{
printf("** Player not found **\n");
}
else
{
   printf("Enter player first or nick name:");
       scanf("%s",&newName);
      
printf("Enter a new rating for player\n");
newrate = getValidRating();
  
rating[indx]=newrate;
strcpy(name[indx],newName);
               }

continue;
}
case 'r':
case 'R':
{
int flag=0;
printf("Enter a jersey number :");
jno=getValidJerseyNumber();
for (i = 0; i < count; i++)
{
if (jerseyNo[i] == jno)
{
for(j=i;j<count-1;j++)
{
jerseyNo[j]=jerseyNo[j+1];
rating[j]=rating[j+1];
}
flag = 1;
count--;
}
}
if (flag == 0)
{
printf("** Player not found **\n");
}
continue;
}

case 'd':
case 'D':
{
   int flag=0;
   int indx=0;
   printf("Enter player jersey number:");
   jno = getValidJerseyNumber();
     
                for (i = 0; i < count; i++)
{
if (jerseyNo[i] == jno)
{
indx=i;
flag = 1;
}
}
if (flag == 0)
{
printf("** Player not found **\n");
}
else
{
   printf("\nDisplaying Player Info::\n");
   printf("Name:%s\n",name[indx]);
   printf("Jersey #:%d\n",jerseyNo[indx]);
   printf("Rating:%d\n",rating[indx]);
  
               }
     
      
   continue;
}
  
case 's':
case 'S':
{

printf("Enter a rating \n");
rate = getValidRating();
printf("Above%d\n", rate);
for (i = 0; i < count; i++)
{
if (rating[i] > rate)
printf("Player %d -- Jersey Number:%d, Name:%s, Rating:%d\n", i + 1, jerseyNo[i],name[i]
,rating[i]);
}
continue;
}
case 'p':
case 'P':
{
printf("\nROSTER\n");
for (i = 0; i < count; i++)
{
printf("Player %d -- Jersey Number:%d, Name:%s, Rating:%d\n", i + 1, jerseyNo[i],name[i]
,rating[i]);
}
continue;
}
case 'Q':
case 'q':
{

break;
}
default:
{
printf("** Invalid Option **\n");
continue;
}
}
break;
}


return 0;
}
// This function will get the valid jersey number from the user
int getValidJerseyNumber()
{
int jerseyNum;
while (1)
{
scanf("%d", &jerseyNum);
if (jerseyNum < 0 || jerseyNum > 99)
{
printf("Invalid must be between 0-99\n");
printf("Re-Enter:\n");

continue;
}
else
{
break;
}
}
return jerseyNum;
}
// This function will get the valid rating from the user
int getValidRating()
{
int rate;
while (1)
{
scanf("%d", &rate);
if (rate < 1 || rate > 9)
{
printf("Invalid must be between 1-9\n");
printf("Re-Enter:\n");

continue;
}
else
{
break;
}
}
return rate;
}

______________________________

Output:

C:Program Files (x86)\Dev-Cpp MinGW64 bin\RosterPlayerJersyNumberRating.exe nter player 1s jersey number 4 nter player first

C:Program Files (x86)\Dev-Cpp MinGW64 bin RosterPlayerJersyNumberRating.exe MENU Add a new player - Update player information

CProgram Files (x86)\Dev-Cpp MinGW641bin\RosterPlayerJersyNumberRating.exe MENU Add a new player - Update player information

C:\Program Files (x86)\Dev-Cpp\MinGw64bin\RosterPlayerlersyNumberRatingexe MENU Add a new player - Update player information


_______________Could you plz rate me well.Thank You

Add a comment
Know the answer?
Add Answer to:
In C Program This program will store the roster and rating information for a soccer team. There w...
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
  • 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:...

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

  • 5.19 Lab 11b: Soccer team roster Instructor note: NOTE Unlike our other assignments, this one has...

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

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

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

  • I need to update this C++ code according to these instructions. The team name should be...

    I need to update this C++ code according to these instructions. The team name should be "Scooterbacks". I appreciate any help! Here is my code: #include <iostream> #include <string> #include <fstream> using namespace std; void menu(); int loadFile(string file,string names[],int jNo[],string pos[],int scores[]); string lowestScorer(string names[],int scores[],int size); string highestScorer(string names[],int scores[],int size); void searchByName(string names[],int jNo[],string pos[],int scores[],int size); int totalPoints(int scores[],int size); void sortByName(string names[],int jNo[],string pos[],int scores[],int size); void displayToScreen(string names[],int jNo[],string pos[],int scores[],int size); void writeToFile(string...

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

  • Need C programming help. I've started to work on the program, however I struggle when using...

    Need C programming help. I've started to work on the program, however I struggle when using files and pointers. Any help is appreciated as I am having a hard time comleting this code. #include <stdio.h> #include <stdlib.h> #include <string.h> #define MAX_LINE 100 #define MAX_NAME 30 int countLinesInFile(FILE* fPtr); int findPlayerByName(char** names, char* target, int size); int findMVP(int* goals, int* assists, int size); void printPlayers(int* goals, int* assists, char** names, int size); void allocateMemory(int** goals, int** assists, char*** names, int size);...

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