Question: THIS IS FOR C PROGRAMMING!!! Create a program that reads student information from a file, populates each student as a record in a linked list,

THIS IS FOR C PROGRAMMING!!! Create a program that reads student information from a file, populates each student as a record in a linked list, and has some code to read/report values from the linked list data structure.

Do not hardcode an array of structures for this program. The purpose is to learn how to manipulate memory dynamically.

The data must be stored as a linked list. Do not just read the file and calculate the results while you are reading the values. Once again, this is to ensure that you are manipulating memory.

Do not change the function prototypes to get your code to work.

YOU ONLY NEED TO WORK ON THE AREAS WHERE IT SAYS "TODO"

#include  #include  #include  typedef struct student_struct { char name[16]; int age; float gpa; struct student_struct *next; } Student; Student head; //The head of the linked list /* Given the student values, initialize a structure, and return a pointer to the struct */ Student *makeStudent(char name[16], int age, double gpa) { //TODO: Implement this function return NULL; //Change return value.... } /* Inserts an element to the front of the linkedList */ void push(Student *student) { //TODO: Implement this function } /* Traverses the linked list and returns the student with the best GPA */ Student *findTopStudent() { //TODO: Implement this function return NULL; //Change return value } /* Traverses the linked list and returns the average GPA across all students */ float getAverageGPA() { //TODO: Implement this function return 0.0; //Change return value } int main(int argc, char **argv) { if(argc != 2){ perror("ERROR: Wrong number of command line args! "); return -1; } head.next = NULL; //initialize that the linked list is empty. FILE * file; file = fopen(argv[1] , "r"); if (!file){ perror("ERROR opening file! "); return -1; } //------------------------------------------------- // TODO: Change main method code BELOW char s1[16]; char s2[16]; char s3[16]; while (fscanf(file, "%s %s %s", s1,s2,s3)!=EOF) { printf("READING FILE LINE: %s %s %s ",s1, s2, s3); } fclose(file); // TODO: Change main method code ABOVE //------------------------------------------------- Student *topStudent = findTopStudent(); printf("The Student with the best GPA is: %s ", topStudent->name); printf("The average GPA is: %.2f ", getAverageGPA()); return 0; }

I have also attached data1.txt, STORE THIS AS A .txt FILE to implement in the program

data1.txt

Mary 23 3.5 Jane 34 3.6 Mark 23 3.3 Joe 23 2.5 Bill 23 1.3 Sam 23 2.1 Rebecca 23 3.9 Lowie 23 2.8 Will 23 3.1 John 23 2.2 Bonnie 23 3.2

IF DONE CORRECTLY, PROGRAM SHOULD GIVE THIS RESULT:

Test Case for data1.txt

THIS IS FOR C PROGRAMMING!!! Create a program that reads student information

user@a5c9a88fcd15:/projects/HW4$ ./hw4 data1.txt The student with the best GPA is: Rebecca The average GPA is: 2.86 user@a5c9a88fcd15:/projects/HW4$

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!