ComputerScienceExpert

(11)

$18/per page/

About ComputerScienceExpert

Levels Tought:
Elementary,Middle School,High School,College,University,PHD

Expertise:
Applied Sciences,Calculus See all
Applied Sciences,Calculus,Chemistry,Computer Science,Environmental science,Information Systems,Science Hide all
Teaching Since: Apr 2017
Last Sign in: 103 Weeks Ago, 3 Days Ago
Questions Answered: 4870
Tutorials Posted: 4863

Education

  • MBA IT, Mater in Science and Technology
    Devry
    Jul-1996 - Jul-2000

Experience

  • Professor
    Devry University
    Mar-2010 - Oct-2016

Category > Programming Posted 29 May 2017 My Price 8.00

Project 10The programroster.cmaintains a roster

Help in completing this assignment. please make sure to read the instructions file attached. the program has to be as requested in the instructions file. 

thank you 

 

Project 10The programroster.cmaintains a roster for a sports team. Each player has a last name, firstname, and a number. Complete the program so it uses a dynamically allocated linked list to storethe roster and have the following functions:1.append_to_list: ask the user to enter player’s last name, first name and number, then addthe player to theendof the linked list.a.It should check whether the player has already existed by number. If so, the functionshould print a message and exit.b.If the player does not exist, allocate memory for the player, store the data, and appendthe player to the end of the linked list.c.If the list is empty, the function should return the pointer to the newly created player.d.Otherwise, add the player to the end of the linked list and return the pointer to thelinked list.2.find_player: find the player name by name, print the player’s last name and first name inthe format “last name, first name”. If the player is not found, print a message.3.printList: print the name and number of all the players.4.clearList: when the user exists the program, all the memory allocated for the linked listshould be deallocated.Note: use read_line function included in the program for reading in last names and first names.GradingTotal points: 1001.A program that does not compile will result in a zero.2.Runtime error and compilation warning 5%3.Commenting and style 15%4.Functionality 80%:a.Function implementation meets the requirement.b.Function process the linked list by using the malloc and free function properly.Before you submit1. Compile with –Wall. Be sure it compiles oncircewith no errors and no warnings.gcc –Wall roster.c2. Be sure your Unix source file is read & write protected. Change Unix file permission on Unix:chmod 600 roster.c3. Test your program with Unix Shell script try_roster

#include <stdio.h>#include <string.h>#include <ctype.h>#define NAME_LEN 30struct player{int number;char first_name[NAME_LEN+1];char last_name[NAME_LEN+1];struct player *next;};struct player *append_to_list(struct player *roster);void find_player(struct player *roster);void printList(struct player *roster);void clearList(struct player *roster);int read_line(char str[], int n);/*********************************************************** main: Prompts the user to enter an operation code,**then calls a function to perform the requested**action. Repeats until the user enters the**command 'q'. Prints an error message if the user **enters an illegal code.***********************************************************/int main(void){char code;struct player *team_roster = NULL;printf("Operation Code: a for appending to the roster, f for finding a player"", p for printing the roster; q for quit.\n");for (;;) {printf("Enter operation code: ");scanf(" %c", &code);while (getchar() != '\n')/* skips to end of line */;switch (code) {case 'a': team_roster = append_to_list(team_roster);break;case 'f': find_player(team_roster);break;case 'p': printList(team_roster);break;case 'q': clearList(team_roster);return 0;default:printf("Illegal code\n");}printf("\n");}}struct player *append_to_list(struct player *roster){//add your code here and remove the return NULL; statementreturn NULL;}void find_player(struct player *roster){//add your code here}

Answers

(11)
Status NEW Posted 29 May 2017 03:05 AM My Price 8.00

-----------

Not Rated(0)