The goal of this assignment is threefold: work with structs, work with linked lists, implement a “database-like” program that stores records that can be queried. Specifically, in this assignment, you will create a struct person and use it to create a struct node so that you can store a linked list of persons. You will then create a struct family and finally an array of struct family. A single struct family will store individual person structs in a linked list. You will implement various linked list functions and some other functions (described later).
A person will consist of:
A node will consist of:
Assume that the struct person member has the name me (as used below).
A family will consist of
You will create an array of your struct family, e.g., struct family families[10]; You will need no more than 10 array elements. To access a family, use families[i]. To access the linked list, use families[i].front. Given a struct node *temp, which is a node in a linked list, access that person’s name, age and sex using temp->me.first, temp->me.age, temp->me.sex. You are free to name your structs, members and array variable anything you like, the examples here are just to help you understand the structure of these three struct types and how to access into them.
Your program may consist of a single file or multiple files, your choice. You may but do not need a header file. Either way, make sure you comment your function prototypes! Your struct definitions should either be at the top of your single .c file if you only have one or in your .h file if you choose to use a header file. NOTE: define the structs in the order listed above because person is used in node and node is used in family.
Aside from main, you will need the following functions (at a minimum):
a new node, copy into this node the person’s first name, age, sex, and insert the node into the linked list, returning a node pointer to the front of the list (needed when inserting into an empty list or at the front of a list).
You may write other functions if or as needed.
In main, declare your array of struct family elements (no more than 10 are needed). Declare the array statically (do not use a pointer/calloc), and declare any variables you need. Initialize your array of family elements by setting each element’s size to 0 and front pointer to NULL. You do not need to initialize the last names but if you do make sure you assign them using strcpy, not = as in strcpy(families[i].last, “”); Next in main, use a while loop to iterate through the contents of the input file until you reach EOF. This might look like what you implemented in program 2, for instance while(getInput(…)!=EOF) {…} or you can test for feof. The input function will need to input one row of the input text file which will consist of a first name, last name, age and sex.
strcpy(temp->me.first, first); temp->me.age=age;
temp->me.sex=sex;
After exiting the while loop having inserted all new people into an appropriate linked list, do the following. Make sure you close the input file when done with it
Use a for-loop to iterate through all n families and print out all of the families using your outputFamily function. This function receives families[i].front and families[i].lastName so that the function can print out the family’s last name and then each first name in the linked list.
After the for-loop, prompt the user to enter an age (I’m calling it inputAge). Use a while loop that iterates while inputAge > 0. Search all of the families for anyone whose age is equal to the input age and output that person’s first and last names. This requires a for-loop inside the while loop to iterate through all n families, passing inputAge, families[i].lastName and families[i].front to the ageSearch function. If a family member is found for the given age, output that person’s first and last name. This while loop ends with another input for the next inputAge value. Upon entering 0 (or negative), exit the loop
Next, call the smallestLargest function, passing it the entire families array and n. This function locates and outputs the entire family information for the smallest family and the largest family. Make sure you output which is which.
Finally, pass to a destroy function the families array and n. This function uses a for-loop to iterate through each family[i] and an inner while loop to iterate through each node of this family’s linked list, freeing each node. After destroying a linked list, reset families[i].size to 0 and families.lastName to “” (again, using strcpy).
Run your program on the two data files on the website. An example of output from the first run is shown below. To fully test yours, use for inputAge these values: 53, 29, 57, 54 and 0.
Printing all families
Howe family: Dylan, Georgia, Janet, Steve, Virgil, Underwood family: Ian, Ruth,
Zappa family: Diva, Dweezil, Frank, Gail, Moon, Wakeman family: Jemma, Oliver, Rachel, Rick, Hackett family: Jo, John, Steve,
Enter an age to search for: 53 Searching for all people of age 53:
Frank Zappa, Rachel Wakeman,
CS 340 Milestone One Guidelines and Rubric Overview: For this assignment, you will implement the fundamental operations of create, read, update,
Retail Transaction Programming Project Project Requirements: Develop a program to emulate a purchase transaction at a retail store. This
7COM1028 Secure Systems Programming Referral Coursework: Secure
Create a GUI program that:Accepts the following from a user:Item NameItem QuantityItem PriceAllows the user to create a file to store the sales receip
CS 340 Final Project Guidelines and Rubric Overview The final project will encompass developing a web service using a software stack and impleme