Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

/ / / = = = = = = = = = = = = PART 1 : FIXED code = = = = =

///============ PART 1: FIXED code ==========///
///====== DON'T CHANGE THIS PART ============///
#include
#include
#define MAX_WORD_CHAR 100
#define GPA "GPA"
#define DATE "DATE"
struct Date
{
int year;
int month;
int day;
};
typedef struct Date Date;
struct Node
{
Date dob;
float gpa;
struct Node *next;
};
typedef struct Node Node;
void readData(FILE *, char **, float *, Node **, Node **);
Node *mergeList(Node *, Node *);
Node *filterList(Node *, char *, float);
Node *reverseList(Node *);
void printList(Node *);
int main()
{
FILE *fp = fopen("DATA.IN","r");
Node *headL1= NULL;
Node *headL2= NULL;
char *controlString;
float targetGPA;
readData(fp, &controlString, &targetGPA, &headL1, &headL2);
printList(headL1);
printf("
");
printList(headL2);
printf("
");
Node *head = mergeList(headL1, headL2);
head = filterList(head, controlString, targetGPA);
head = reverseList(head);
printList(head);
fclose(fp);
}
///============ PART 2: Student works ==========///
// Define supported functions here.
//
void readData(FILE *fp, char **controlString, float *targetGPA, Node **headL1, Node **headL2)
{
// TODO: read data with file pointer fp:
// LINE1: controlString targetGPA
//(LT or GT)(float number)
// LINE2: headL1 is the head of list
// LINE3: headL2 is the head of list
}
Node *mergeList(Node *headL1, Node *headL2)
{
// TODO: add list 2 into the end of list 1, return the head of result list
}
Node *filterList(Node *head, char *controlString, float targetGPA)
{
/*
TODO: Filter the third list based on GPA criteria.
If controlString is "LT", filter the students with a GPA less than targetGPA.
If controlString is "GT", filter the students with a GPA greater than targetGPA.
return head of filtered list
*/
}
Node *reverseList(Node *head)
{
// TODO: reverse the list
// return the new head
}
void printList(Node *head)
{
// TODO: print the linked list to stdout
}

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

Database Marketing The Ultimate Marketing Tool

Authors: Edward L. Nash

1st Edition

0070460639, 978-0070460638

More Books

Students also viewed these Databases questions

Question

places. Activity Frame The market is by % .

Answered: 1 week ago