Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Using the program segment and sample txt file below, write a program that contains a linked list of students. The program should allow the user

Using the program segment and sample txt file below, write a program that contains a linked list of students. The program should allow the user to:

1. initialize list of students

2. add additional student to front of list

3. add additional student to rear of list

4. delete student

5. sort students alphabetically

6. sort students by idNum

7. show number of students in list

8. print students

9. quit program

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

The program should be divided into the following segments

1. mainDriver.c. (contains main()function) 2. sll_list.h (given below. header file for this singly linked-list program) 3. sll_list.c (implementation file for singly linked-list program) 4. students.txt (given below, contains students for initializing linked-list)

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Function prototypes:

list_t *newList( ); // creates a new list; returns a pointer to the new list

student_t *addStudent( FILE *inFile, int whichInput ); // called by addToFront() and addToRear() functions // creates and initializes new student node from input file pointer sent in (either file pointer specified on command-line or stdin that has been reset) // whichInput is intended to be a flag will which determine if the user prompts are to be printed or not // returns a pointer to the student that was just created

int printMenu( ); // prints the menu to the user; returns the menu choice

void initializeList( list_t *list, FILE *inFile ); // calls addToFront() sending input file pointer (file specified at the command-line) // note first value in input file is number of students in file the first value read in from file so you know how many times the loop needs to go

void addToFront( list_t *list, int whichInput, FILE *inFile ); // creates new student by calling addStudent() then adds returned student to front of list

void addToRear( list_t *list, int whichInput, FILE *inFile ); // creates new student by calling addStudent() then adds returned student to end of list

void deleteStudent( list_t *list, int idNum ); // deletes the student with the cuid sent in as idNum

void sortListByLN( list_t *list ); // sorts the list alpahabetically by last name

void sortListByNum( list_t *list ); // sorts the list by cuid

int size( list_t *list ); // returns the size of the list

int isEmpty( list_t *list ); // returns 1 if the list is empty and 0 if it is not empty

void printStudents ( list_t *list ); // prints the students in the list

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX // ssl_list.h //

#ifndef SLL_LIST_H #define SLL_LIST_H

typedef struct { char month[4]; int day, year; } dateOfBirth;

typedef struct student { int age; float gpa; int Num; dateOfBirth dob; char lastName[20]; char firstName[15]; struct student *next; } student_t;

typedef struct list { student_t *head; student_t *tail; int size; } list_t;

list_t *newList( ); student_t *addStudent( FILE *inFile, int whichInput ); int printMenu( ); void initializeList( list_t *list, FILE *inFile ); void addToFront( list_t *list, int whichInput, FILE *inFile ); void addToRear( list_t *list, int whichInput, FILE *inFile ); void deleteStudent( list_t *list, int Num ); void sortListByLN( list_t *list ); void sortListByNum( list_t *list ); int size( list_t *list ); int isEmpty( list_t *list ); void printStudents ( list_t *list );

#endif /* SLL_LIST_H */

XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXx

students.txt

5 19 3.2 123456789 Jan 31 1999 Smith David 20 3.0 456789123 Mar 7 1998 Jackson Susan 18 2.9 789123456 May 14 2000 Miller Scott 19 3.4 987654321 Sep 12 1999 Wilson Marie 20 3.7 654321987 Jun 21 1998 Johnson Curtis

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Logic In Databases International Workshop Lid 96 San Miniato Italy July 1 2 1996 Proceedings Lncs 1154

Authors: Dino Pedreschi ,Carlo Zaniolo

1st Edition

3540618147, 978-3540618140

More Books

Students also viewed these Databases questions

Question

What are the need and importance of training ?

Answered: 1 week ago

Question

What is job rotation ?

Answered: 1 week ago